Skip to content

Commit 4017171

Browse files
committed
Response to feedback: remove add_background and use constructor; remove unnecessary sorting
1 parent dd145a2 commit 4017171

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/pytest_bdd/parser.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ class Rule:
109109
tags: set[str]
110110
background: Background | None = None
111111

112-
def add_background(self, background: Background) -> None:
113-
self.background = background
114-
115112

116113
@dataclass(eq=False)
117114
class ScenarioTemplate:
@@ -492,19 +489,16 @@ def parse(self) -> Feature:
492489

493490
def _parse_and_add_rule(self, rule_data: GherkinRule, feature: Feature) -> None:
494491
"""Parse a rule, including its background and scenarios, and add to the feature."""
492+
background = self._extract_rule_background(rule_data)
493+
495494
rule = Rule(
496495
keyword=rule_data.keyword,
497496
name=rule_data.name,
498497
description=rule_data.description,
499498
tags=self.get_tag_names(rule_data.tags),
499+
background=background,
500500
)
501501

502-
# Add background if present within the rule
503-
background = self._extract_rule_background(rule_data)
504-
if background:
505-
rule.add_background(background)
506-
507-
# Parse and add scenarios under the rule
508502
for scenario in self._extract_rule_scenarios(rule_data, feature, rule):
509503
feature.scenarios[scenario.name] = scenario
510504

src/pytest_bdd/reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def serialize(self) -> dict[str, Any]:
130130
"keyword": scenario.rule.keyword,
131131
"name": scenario.rule.name,
132132
"description": scenario.rule.description,
133-
"tags": sorted(scenario.rule.tags),
133+
"tags": scenario.rule.tags,
134134
}
135135

136136
return serialized

0 commit comments

Comments
 (0)