Regression test case for https://github.com/pytest-dev/pytest/issues/2836
(pytester: Pytester)
| 1001 | |
| 1002 | |
| 1003 | def test_fixture_scope_sibling_conftests(pytester: Pytester) -> None: |
| 1004 | """Regression test case for https://github.com/pytest-dev/pytest/issues/2836""" |
| 1005 | foo_path = pytester.mkdir("foo") |
| 1006 | foo_path.joinpath("conftest.py").write_text( |
| 1007 | textwrap.dedent( |
| 1008 | """\ |
| 1009 | import pytest |
| 1010 | @pytest.fixture |
| 1011 | def fix(): |
| 1012 | return 1 |
| 1013 | """ |
| 1014 | ) |
| 1015 | ) |
| 1016 | foo_path.joinpath("test_foo.py").write_text("def test_foo(fix): assert fix == 1") |
| 1017 | |
| 1018 | # Tests in `food/` should not see the conftest fixture from `foo/` |
| 1019 | food_path = pytester.mkpydir("food") |
| 1020 | food_path.joinpath("test_food.py").write_text("def test_food(fix): assert fix == 1") |
| 1021 | |
| 1022 | res = pytester.runpytest() |
| 1023 | assert res.ret == 1 |
| 1024 | |
| 1025 | res.stdout.fnmatch_lines( |
| 1026 | [ |
| 1027 | "*ERROR at setup of test_food*", |
| 1028 | "E*fixture 'fix' not found", |
| 1029 | "*1 passed, 1 error*", |
| 1030 | ] |
| 1031 | ) |
| 1032 | |
| 1033 | |
| 1034 | def test_collect_init_tests(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected