Skip to content

Commit

Permalink
Fix context for backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Nov 9, 2019
1 parent 3845f62 commit 5151233
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/radish/models/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Background(Scenario):
def __init__(
self, keyword: str, short_description: str, path: str, line: int, steps
) -> None:
super().__init__(0, keyword, short_description, None, path, line, steps)
super().__init__(0, keyword, short_description, [], path, line, steps)

#: Holds the Scenario for which this Background is supposed to run.
self.scenario = None
Expand All @@ -38,6 +38,7 @@ def set_scenario(self, scenario):
and other context sensitive functionalities.
"""
self.scenario = scenario # pragma: no cover
self.context = self.scenario.context

@property
def state(self):
Expand Down
1 change: 1 addition & 0 deletions src/radish/models/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def set_background(self, background):
self.background = copy.deepcopy(background)
self.background.set_scenario(self)
self.background.set_rule(self.rule)
self.background.set_feature(self.feature)

def set_rule(self, rule):
"""Set the Rule for this Scenario"""
Expand Down
8 changes: 4 additions & 4 deletions src/radish/parser/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ def feature_body(self, subtree):

rules = [default_rule] + rules

# add Background to all Rules
for rule in rules:
rule.set_background(background)

return description, background, rules

def feature(self, subtree):
Expand Down Expand Up @@ -354,6 +350,10 @@ def feature(self, subtree):
for rule in rules:
rule.set_feature(feature)

# add Background to all Rules
for rule in rules:
rule.set_background(background)

return feature

def tag(self, subtree):
Expand Down

0 comments on commit 5151233

Please sign in to comment.