Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Dec 2, 2023
1 parent 9c60589 commit ebd76f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/pytest_bdd/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ def duration(self) -> float:
:return: Step execution duration.
:rtype: float
"""
if self.stopped is None:
return 0

return self.stopped - self.started
return 0 if self.stopped is None else self.stopped - self.started


class ScenarioReport:
Expand Down
13 changes: 5 additions & 8 deletions src/pytest_bdd/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def find_fixturedefs_for_step(step: Step, fixturemanager: FixtureManager, nodeid
"""Find the fixture defs that can parse a step."""
# happens to be that _arg2fixturedefs is changed during the iteration so we use a copy
fixture_def_by_name = list(fixturemanager._arg2fixturedefs.items())
for i, (fixturename, fixturedefs) in enumerate(fixture_def_by_name):
for fixturename, fixturedefs in fixture_def_by_name:
for pos, fixturedef in enumerate(fixturedefs):
step_func_context = getattr(fixturedef.func, "_pytest_bdd_step_context", None)
if step_func_context is None:
Expand Down Expand Up @@ -245,14 +245,11 @@ def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str
def collect_example_parametrizations(
templated_scenario: ScenarioTemplate,
) -> list[ParameterSet] | None:
# We need to evaluate these iterators and store them as lists, otherwise
# we won't be able to do the cartesian product later (the second iterator will be consumed)
contexts = list(templated_scenario.examples.as_contexts())
if not contexts:
if contexts := list(templated_scenario.examples.as_contexts()):
return [pytest.param(context, id="-".join(context.values())) for context in contexts]
else:
return None

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


def scenario(
feature_name: str,
Expand All @@ -267,7 +264,7 @@ def scenario(
:param str encoding: Feature file encoding.
"""
__tracebackhide__ = True
scenario_name = str(scenario_name)
scenario_name = scenario_name
caller_module_path = get_caller_module_path()

# Get the feature
Expand Down

0 comments on commit ebd76f5

Please sign in to comment.