Skip to content

Commit

Permalink
Fix Feature assignment to Background
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Nov 9, 2019
1 parent 941f2b6 commit 3845f62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/radish/parser/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ def feature(self, subtree):
self.language_spec,
)

# let the Background know to which Feature it belongs to
if background:
background.set_feature(feature)

# let the Rules know to which Feature they belong
for rule in rules:
rule.set_feature(feature)
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,22 @@ def test_parse_empty_background_with_short_description(parser):
assert ast.background.short_description == "My Background"


def test_parse_background_has_assigned_feature(parser):
"""The parser should assign the Feature to the Background"""
# given
feature_file = """
Feature: My Feature
Background: My Background
"""

# when
ast = parser.parse_contents(None, feature_file)

# then
assert ast.background.feature is not None


@pytest.mark.xfail(
reason="RadishMultipleBackgrounds is not matched. Probably a bug in lark?"
)
Expand Down

0 comments on commit 3845f62

Please sign in to comment.