Using the same given fixture raises an error.
(pytester)
| 308 | |
| 309 | |
| 310 | def 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 | |
| 352 | def test_step_hooks(pytester): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…