Skip to content

Commit ebd76f5

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent 9c60589 commit ebd76f5

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/pytest_bdd/reporting.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ def duration(self) -> float:
6363
:return: Step execution duration.
6464
:rtype: float
6565
"""
66-
if self.stopped is None:
67-
return 0
68-
69-
return self.stopped - self.started
66+
return 0 if self.stopped is None else self.stopped - self.started
7067

7168

7269
class ScenarioReport:

src/pytest_bdd/scenario.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def find_fixturedefs_for_step(step: Step, fixturemanager: FixtureManager, nodeid
4747
"""Find the fixture defs that can parse a step."""
4848
# happens to be that _arg2fixturedefs is changed during the iteration so we use a copy
4949
fixture_def_by_name = list(fixturemanager._arg2fixturedefs.items())
50-
for i, (fixturename, fixturedefs) in enumerate(fixture_def_by_name):
50+
for fixturename, fixturedefs in fixture_def_by_name:
5151
for pos, fixturedef in enumerate(fixturedefs):
5252
step_func_context = getattr(fixturedef.func, "_pytest_bdd_step_context", None)
5353
if step_func_context is None:
@@ -245,14 +245,11 @@ def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str
245245
def collect_example_parametrizations(
246246
templated_scenario: ScenarioTemplate,
247247
) -> list[ParameterSet] | None:
248-
# We need to evaluate these iterators and store them as lists, otherwise
249-
# we won't be able to do the cartesian product later (the second iterator will be consumed)
250-
contexts = list(templated_scenario.examples.as_contexts())
251-
if not contexts:
248+
if contexts := list(templated_scenario.examples.as_contexts()):
249+
return [pytest.param(context, id="-".join(context.values())) for context in contexts]
250+
else:
252251
return None
253252

254-
return [pytest.param(context, id="-".join(context.values())) for context in contexts]
255-
256253

257254
def scenario(
258255
feature_name: str,
@@ -267,7 +264,7 @@ def scenario(
267264
:param str encoding: Feature file encoding.
268265
"""
269266
__tracebackhide__ = True
270-
scenario_name = str(scenario_name)
267+
scenario_name = scenario_name
271268
caller_module_path = get_caller_module_path()
272269

273270
# Get the feature

0 commit comments

Comments
 (0)