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

Function test_step_functions_same_parser

tests/steps/test_common.py:123–168  ·  view source on GitHub ↗
(pytester)

Source from the content-addressed store, hash-verified

121
122
123def test_step_functions_same_parser(pytester):
124 pytester.makefile(
125 ".feature",
126 target_fixture=textwrap.dedent(
127 """\
128 Feature: A feature
129 Scenario: A scenario
130 Given there is a foo with value "(?P<value>\\w+)"
131 And there is a foo with value "testfoo"
132 When pass
133 Then pass
134 """
135 ),
136 )
137 pytester.makepyfile(
138 textwrap.dedent(
139 """\
140 import pytest
141 from pytest_bdd import given, when, then, scenarios, parsers
142 from pytest_bdd.utils import dump_obj
143
144 scenarios("target_fixture.feature")
145
146 STEP = r'there is a foo with value "(?P<value>\\w+)"'
147
148 @given(STEP)
149 def _():
150 dump_obj(('str',))
151
152 @given(parsers.re(STEP))
153 def _(value):
154 dump_obj(('re', value))
155
156 @when("pass")
157 @then("pass")
158 def _():
159 pass
160 """
161 )
162 )
163 result = pytester.runpytest("-s")
164 result.assert_outcomes(passed=1)
165
166 [first_given, second_given] = collect_dumped_objects(result)
167 assert first_given == ("str",)
168 assert second_given == ("re", "testfoo")
169
170
171def test_user_implements_a_step_generator(pytester):

Callers

nothing calls this directly

Calls 1

collect_dumped_objectsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…