Skip to content

Commit

Permalink
descriptive docstrings, drop dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
bradsbrown committed Apr 16, 2020
1 parent 24e7948 commit 07578be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 11 additions & 1 deletion sphinx_gherkindoc/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ def __init__(self, data):
self._data = data

def __getattr__(self, key):
"""Grab attribute from wrapped class, if present."""
"""Grab attribute from wrapped class, if present.
When inheriting this model,
properties may need to be added to the subclass
in cases where a specific ``behave`` attribute
does not exist on the underlying class,
or where the format returned from the underlying attribute
does not match the ``behave`` format.
"""
if key == "description":
# Workaround for current pytest-bdd release (3.2.1),
# which does not have a scenario.description attribute.
return getattr(self._data, key, None)
return getattr(self._data, key)

Expand Down
15 changes: 11 additions & 4 deletions tests/test_pytest_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ def _reformat_keywords(rst_lines):

@pytest.fixture()
def pytest_rst_output():
"""Adjust expected rst output to align with pytest-bdd parser formats.
One change is necessary between ``behave`` and ``pytest-bdd`` formats.
Backgrounds and Examples in pytest-bdd do not have descriptions/titles,
so "Background: Stuff I Need" will become simply "Background:", for example.
As part of this change, the section header underline will also be adjusted
to match length.
This fixture creates a copy of the ``behave`` expected rst output module,
with that change made.
"""
base_rst_output = SimpleNamespace()
for attribute in dir(rst_output):
if not attribute.startswith("_"):
Expand All @@ -42,17 +53,13 @@ def feature_file_pytest(tmp_path):
test_dir = pathlib.Path(__file__).parent
basic_feature = test_dir / "basic_pytest.feature"
return basic_feature
# with open(test_dir / "basic_pytest.feature") as feature_fo:
# basic_feature.write_text(feature_fo.read())


@pytest.fixture()
def tags_feature_file_pytest(tmp_path):
test_dir = pathlib.Path(__file__).parent
tags_feature = test_dir / "tags_pytest.feature"
return tags_feature
# with open(test_dir / "tags_pytest.feature") as feature_fo:
# tags_feature.write_text(feature_fo.read())


def pytest_writer(*args, **kwargs):
Expand Down

0 comments on commit 07578be

Please sign in to comment.