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

Function test_multiple_given

tests/feature/test_steps.py:310–349  ·  view source on GitHub ↗

Using the same given fixture raises an error.

(pytester)

Source from the content-addressed store, hash-verified

308
309
310def test_multiple_given(pytester):
311 """Using the same given fixture raises an error."""
312 pytester.makefile(
313 ".feature",
314 steps=textwrap.dedent(
315 """\
316 Feature: Steps are executed one by one
317 Scenario: Using the same given twice
318 Given foo is "foo"
319 And foo is "bar"
320 Then foo should be "bar"
321
322 """
323 ),
324 )
325 pytester.makepyfile(
326 textwrap.dedent(
327 """\
328 from pytest_bdd import parsers, given, then, scenario
329
330
331 @given(parsers.parse("foo is {value}"), target_fixture="foo")
332 def _(value):
333 return value
334
335
336 @then(parsers.parse("foo should be {value}"))
337 def _(foo, value):
338 assert foo == value
339
340
341 @scenario("steps.feature", "Using the same given twice")
342 def test_given_twice():
343 pass
344
345 """
346 )
347 )
348 result = pytester.runpytest()
349 result.assert_outcomes(passed=1, failed=0)
350
351
352def test_step_hooks(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…