(pytester: Pytester)
| 397 | |
| 398 | |
| 399 | def test_fixture_dependency(pytester: Pytester) -> None: |
| 400 | pytester.makeconftest("") |
| 401 | pytester.path.joinpath("__init__.py").touch() |
| 402 | sub = pytester.mkdir("sub") |
| 403 | sub.joinpath("__init__.py").touch() |
| 404 | sub.joinpath("conftest.py").write_text( |
| 405 | textwrap.dedent( |
| 406 | """\ |
| 407 | import pytest |
| 408 | |
| 409 | @pytest.fixture |
| 410 | def not_needed(): |
| 411 | assert False, "Should not be called!" |
| 412 | |
| 413 | @pytest.fixture |
| 414 | def foo(): |
| 415 | assert False, "Should not be called!" |
| 416 | |
| 417 | @pytest.fixture |
| 418 | def bar(foo): |
| 419 | return 'bar' |
| 420 | """ |
| 421 | ) |
| 422 | ) |
| 423 | subsub = sub.joinpath("subsub") |
| 424 | subsub.mkdir() |
| 425 | subsub.joinpath("__init__.py").touch() |
| 426 | subsub.joinpath("test_bar.py").write_text( |
| 427 | textwrap.dedent( |
| 428 | """\ |
| 429 | import pytest |
| 430 | |
| 431 | @pytest.fixture |
| 432 | def bar(): |
| 433 | return 'sub bar' |
| 434 | |
| 435 | def test_event_fixture(bar): |
| 436 | assert bar == 'sub bar' |
| 437 | """ |
| 438 | ) |
| 439 | ) |
| 440 | result = pytester.runpytest("sub") |
| 441 | result.stdout.fnmatch_lines(["*1 passed*"]) |
| 442 | |
| 443 | |
| 444 | def test_conftest_found_with_double_dash(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected