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

Function test_step_alias

tests/feature/test_alias.py:6–60  ·  view source on GitHub ↗
(pytester)

Source from the content-addressed store, hash-verified

4
5
6def 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)

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…