diff --git a/src/pytest_bdd/scenario.py b/src/pytest_bdd/scenario.py index 30a9b97e..004fb7ea 100644 --- a/src/pytest_bdd/scenario.py +++ b/src/pytest_bdd/scenario.py @@ -167,7 +167,7 @@ def _execute_step_function( inject_fixture(request=request, arg=arg, value=return_value) else: target_fixture_tokens = [token for token in context.target_fixture.split(",") if token] - # Single return value in target_fixture + # Single return value in target_fixture if len(target_fixture_tokens) == 1: inject_fixture(request=request, arg=target_fixture_tokens[0], value=return_value) # Multiple comma separated return values in target_fixture diff --git a/src/pytest_bdd/steps.py b/src/pytest_bdd/steps.py index b29cb419..fd9f8338 100644 --- a/src/pytest_bdd/steps.py +++ b/src/pytest_bdd/steps.py @@ -111,7 +111,14 @@ def when( :return: Decorator function for the step. """ - return step(name, WHEN, converters=converters, target_fixture=target_fixture, target_exception=target_exception, stacklevel=stacklevel) + return step( + name, + WHEN, + converters=converters, + target_fixture=target_fixture, + target_exception=target_exception, + stacklevel=stacklevel, + ) def then( diff --git a/tests/feature/test_steps.py b/tests/feature/test_steps.py index 343cff2d..99ccaac6 100644 --- a/tests/feature/test_steps.py +++ b/tests/feature/test_steps.py @@ -609,7 +609,7 @@ def test_when_exception(pytester): @scenario("when_exception.feature", "Test when exception is generated") def test_when_exception(): pass - + @when("I have injected exception", target_fixture="foo") def _(): return Exception("Dummy Exception obj")