File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -245,7 +245,19 @@ def _execute_step_function(
245
245
246
246
# Execute the step as if it was a pytest fixture using `call_fixture_func`,
247
247
# so that we can allow "yield" statements in it
248
- return_value = call_fixture_func (fixturefunc = context .step_func , request = request , kwargs = kwargs )
248
+ try :
249
+ return_value = call_fixture_func (fixturefunc = context .step_func , request = request , kwargs = kwargs )
250
+ except BaseException as e :
251
+ # BaseException needed to catch pytest.fail.
252
+
253
+ # HACK: call_fixture_func will appear in the traceback whenever a
254
+ # step fails. This is ugly and irrelevant, so this hack will hide
255
+ # it by injecting __tracebackhide__ into the local variables of the
256
+ # stack trace. This is always the second frame, and this is safe
257
+ # because this is the frame of code that is no longer running.
258
+ if e .__traceback__ is not None and e .__traceback__ .tb_next is not None :
259
+ e .__traceback__ .tb_next .tb_frame .f_locals ["__tracebackhide__" ] = True
260
+ raise
249
261
250
262
except Exception as exception :
251
263
request .config .hook .pytest_bdd_step_error (exception = exception , ** kw )
Original file line number Diff line number Diff line change @@ -181,7 +181,6 @@ def test_scenario_1():
181
181
)
182
182
result = pytester .runpytest ("--gherkin-terminal-reporter" , "--showlocals" )
183
183
result .assert_outcomes (passed = 0 , failed = 1 )
184
- result .stdout .fnmatch_lines ("""request*=*<FixtureRequest for *""" )
185
184
result .stdout .fnmatch_lines ("""local_var*=*MULTIPASS*""" )
186
185
187
186
You can’t perform that action at this time.
0 commit comments