Skip to content

Commit 23d21a9

Browse files
committed
Small refactoring
1 parent 928617e commit 23d21a9

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

pytest_reportportal/service.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,22 @@ def _finish_bdd_step(self, leaf: Dict[str, Any], status: str) -> None:
12251225
reporter.finish_nested_step(item_id, timestamp(), status)
12261226
leaf["exec"] = ExecStatus.FINISHED
12271227

1228+
def _is_background_step(self, step: Step, feature: Feature) -> bool:
1229+
"""Check if step belongs to feature background.
1230+
1231+
:param step: Current step
1232+
:param feature: Current feature
1233+
:return: True if step is from background, False otherwise
1234+
"""
1235+
if not feature.background:
1236+
return False
1237+
1238+
background_steps = feature.background.steps
1239+
return any(
1240+
s.name == step.name and s.keyword == step.keyword and s.line_number == step.line_number
1241+
for s in background_steps
1242+
)
1243+
12281244
@check_rp_enabled
12291245
def start_bdd_step(self, feature: Feature, scenario: Scenario, step: Step) -> None:
12301246
"""Start BDD step.
@@ -1244,16 +1260,7 @@ def start_bdd_step(self, feature: Feature, scenario: Scenario, step: Step) -> No
12441260
scenario_leaf["exec"] = ExecStatus.IN_PROGRESS
12451261
reporter = self.rp.step_reporter
12461262
step_leaf = self._create_leaf(LeafType.NESTED, scenario_leaf, step)
1247-
background_steps = []
1248-
if feature.background:
1249-
background_steps = feature.background.steps
1250-
if next(
1251-
filter(
1252-
lambda s: s.name == step.name and s.keyword == step.keyword and s.line_number == step.line_number,
1253-
background_steps,
1254-
),
1255-
None,
1256-
):
1263+
if self._is_background_step(step, feature):
12571264
background_leaf = scenario_leaf["children"][feature.background]
12581265
background_leaf["children"][step] = step_leaf
12591266
if background_leaf["exec"] != ExecStatus.IN_PROGRESS:

0 commit comments

Comments
 (0)