MCPcopy Create free account
hub / github.com/pytest-dev/pytest-bdd / test_step_hooks

Function test_step_hooks

tests/feature/test_steps.py:352–460  ·  view source on GitHub ↗

When step fails.

(pytester)

Source from the content-addressed store, hash-verified

350
351
352def test_step_hooks(pytester):
353 """When step fails."""
354 pytester.makefile(
355 ".feature",
356 test="""
357Feature: StepHandler hooks
358 Scenario: When step has hook on failure
359 Given I have a bar
360 When it fails
361
362 Scenario: When step's dependency a has failure
363 Given I have a bar
364 When its dependency fails
365
366 Scenario: When step is not found
367 Given not found
368
369 Scenario: When step validation error happens
370 Given foo
371 And foo
372 """,
373 )
374 pytester.makepyfile(
375 """
376 import pytest
377 from pytest_bdd import given, when, scenario
378
379 @given('I have a bar')
380 def _():
381 return 'bar'
382
383 @when('it fails')
384 def _():
385 raise Exception('when fails')
386
387 @given('I have a bar')
388 def _():
389 return 'bar'
390
391 @pytest.fixture
392 def dependency():
393 raise Exception('dependency fails')
394
395 @when("its dependency fails")
396 def _(dependency):
397 pass
398
399 @scenario('test.feature', "When step's dependency a has failure")
400 def test_when_dependency_fails():
401 pass
402
403 @scenario('test.feature', 'When step has hook on failure')
404 def test_when_fails():
405 pass
406
407 @scenario('test.feature', 'When step is not found')
408 def test_when_not_found():
409 pass

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…