@@ -80,32 +80,34 @@ def _execute_step_function(
80
80
}
81
81
82
82
request .config .hook .pytest_bdd_before_step (** kw )
83
- try : # TODO: Move this to the places where an exception can actually be raised
84
- # Get the step argument values.
85
- converters = context .converters
86
- kwargs = {}
87
83
88
- for arg , value in context .parser .parse_arguments (step .name ).items ():
89
- if arg in converters :
90
- value = converters [arg ](value )
91
- kwargs [arg ] = value
84
+ # Get the step argument values.
85
+ converters = context .converters
86
+ kwargs = {}
92
87
93
- args = get_args (context .step_func )
94
- kwargs = {arg : kwargs [arg ] if arg in kwargs else request .getfixturevalue (arg ) for arg in args }
95
- kw ["step_func_args" ] = kwargs
88
+ for arg , value in context .parser .parse_arguments (step .name ).items ():
89
+ if arg in converters :
90
+ value = converters [arg ](value )
91
+ kwargs [arg ] = value
96
92
97
- request .config .hook .pytest_bdd_before_step_call (** kw )
93
+ args = get_args (context .step_func )
94
+ kwargs = {arg : kwargs [arg ] if arg in kwargs else request .getfixturevalue (arg ) for arg in args }
95
+ kw ["step_func_args" ] = kwargs
98
96
97
+ request .config .hook .pytest_bdd_before_step_call (** kw )
98
+
99
+ try :
99
100
# Execute the step as if it was a pytest fixture, so that we can allow "yield" statements in it
100
101
return_value = call_fixture_func (fixturefunc = context .step_func , request = request , kwargs = kwargs )
101
- if context .target_fixture is not None :
102
- inject_fixture (request , context .target_fixture , return_value )
103
-
104
- request .config .hook .pytest_bdd_after_step (** kw )
105
102
except Exception as exception :
106
103
request .config .hook .pytest_bdd_step_error (exception = exception , ** kw )
107
104
raise
108
105
106
+ if context .target_fixture is not None :
107
+ inject_fixture (request , context .target_fixture , return_value )
108
+
109
+ request .config .hook .pytest_bdd_after_step (** kw )
110
+
109
111
110
112
def _execute_scenario (feature : Feature , scenario : Scenario , request : FixtureRequest ) -> None :
111
113
"""Execute the scenario.
0 commit comments