(pytester: Pytester)
| 957 | |
| 958 | |
| 959 | def test_setup_only_available_in_subdir(pytester: Pytester) -> None: |
| 960 | sub1 = pytester.mkpydir("sub1") |
| 961 | sub2 = pytester.mkpydir("sub2") |
| 962 | sub1.joinpath("conftest.py").write_text( |
| 963 | textwrap.dedent( |
| 964 | """\ |
| 965 | import pytest |
| 966 | def pytest_runtest_setup(item): |
| 967 | assert item.path.stem == "test_in_sub1" |
| 968 | def pytest_runtest_call(item): |
| 969 | assert item.path.stem == "test_in_sub1" |
| 970 | def pytest_runtest_teardown(item): |
| 971 | assert item.path.stem == "test_in_sub1" |
| 972 | """ |
| 973 | ) |
| 974 | ) |
| 975 | sub2.joinpath("conftest.py").write_text( |
| 976 | textwrap.dedent( |
| 977 | """\ |
| 978 | import pytest |
| 979 | def pytest_runtest_setup(item): |
| 980 | assert item.path.stem == "test_in_sub2" |
| 981 | def pytest_runtest_call(item): |
| 982 | assert item.path.stem == "test_in_sub2" |
| 983 | def pytest_runtest_teardown(item): |
| 984 | assert item.path.stem == "test_in_sub2" |
| 985 | """ |
| 986 | ) |
| 987 | ) |
| 988 | sub1.joinpath("test_in_sub1.py").write_text("def test_1(): pass") |
| 989 | sub2.joinpath("test_in_sub2.py").write_text("def test_2(): pass") |
| 990 | result = pytester.runpytest("-v", "-s") |
| 991 | result.assert_outcomes(passed=2) |
| 992 | |
| 993 | |
| 994 | def test_modulecol_roundtrip(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected