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

Function test_conftest

tests/feature/test_steps.py:260–307  ·  view source on GitHub ↗
(pytester)

Source from the content-addressed store, hash-verified

258
259
260def test_conftest(pytester):
261 pytester.makefile(
262 ".feature",
263 steps=textwrap.dedent(
264 """\
265 Feature: Steps are executed one by one
266 Steps are executed one by one. Given and When sections
267 are not mandatory in some cases.
268
269 Scenario: All steps are declared in the conftest
270 Given I have a bar
271 Then bar should have value "bar"
272
273 """
274 ),
275 )
276 pytester.makeconftest(
277 textwrap.dedent(
278 """\
279 from pytest_bdd import given, then
280
281
282 @given("I have a bar", target_fixture="bar")
283 def _():
284 return "bar"
285
286
287 @then('bar should have value "bar"')
288 def _(bar):
289 assert bar == "bar"
290
291 """
292 )
293 )
294 pytester.makepyfile(
295 textwrap.dedent(
296 """\
297 from pytest_bdd import scenario
298
299 @scenario("steps.feature", "All steps are declared in the conftest")
300 def test_steps():
301 pass
302
303 """
304 )
305 )
306 result = pytester.runpytest()
307 result.assert_outcomes(passed=1, failed=0)
308
309
310def test_multiple_given(pytester):

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…