(pytester)
| 4 | |
| 5 | |
| 6 | def test_step_alias(pytester): |
| 7 | pytester.makefile( |
| 8 | ".feature", |
| 9 | alias=textwrap.dedent( |
| 10 | """\ |
| 11 | Feature: Step aliases |
| 12 | Scenario: Multiple step aliases |
| 13 | Given I have an empty list |
| 14 | And I have foo (which is 1) in my list |
| 15 | # Alias of the "I have foo (which is 1) in my list" |
| 16 | And I have bar (alias of foo) in my list |
| 17 | |
| 18 | When I do crash (which is 2) |
| 19 | And I do boom (alias of crash) |
| 20 | Then my list should be [1, 1, 2, 2] |
| 21 | """ |
| 22 | ), |
| 23 | ) |
| 24 | |
| 25 | pytester.makepyfile( |
| 26 | textwrap.dedent( |
| 27 | """\ |
| 28 | import pytest |
| 29 | from pytest_bdd import given, when, then, scenario |
| 30 | |
| 31 | @scenario("alias.feature", "Multiple step aliases") |
| 32 | def test_alias(): |
| 33 | pass |
| 34 | |
| 35 | |
| 36 | @given("I have an empty list", target_fixture="results") |
| 37 | def _(): |
| 38 | return [] |
| 39 | |
| 40 | |
| 41 | @given("I have foo (which is 1) in my list") |
| 42 | @given("I have bar (alias of foo) in my list") |
| 43 | def _(results): |
| 44 | results.append(1) |
| 45 | |
| 46 | |
| 47 | @when("I do crash (which is 2)") |
| 48 | @when("I do boom (alias of crash)") |
| 49 | def _(results): |
| 50 | results.append(2) |
| 51 | |
| 52 | |
| 53 | @then("my list should be [1, 1, 2, 2]") |
| 54 | def _(results): |
| 55 | assert results == [1, 1, 2, 2] |
| 56 | """ |
| 57 | ) |
| 58 | ) |
| 59 | result = pytester.runpytest() |
| 60 | result.assert_outcomes(passed=1) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…