Directory containing conftest modules are not put in sys.path as a side-effect of importing them.
(self, pytester: Pytester)
| 1420 | ) |
| 1421 | |
| 1422 | def test_conftest(self, pytester: Pytester) -> None: |
| 1423 | """Directory containing conftest modules are not put in sys.path as a side-effect of |
| 1424 | importing them.""" |
| 1425 | tests_dir = pytester.path.joinpath("tests") |
| 1426 | pytester.makepyfile( |
| 1427 | **{ |
| 1428 | "tests/conftest.py": "", |
| 1429 | "tests/test_foo.py": """ |
| 1430 | import sys |
| 1431 | def test_check(): |
| 1432 | assert r"{tests_dir}" not in sys.path |
| 1433 | """.format( |
| 1434 | tests_dir=tests_dir |
| 1435 | ), |
| 1436 | } |
| 1437 | ) |
| 1438 | result = pytester.runpytest("-v", "--import-mode=importlib") |
| 1439 | result.stdout.fnmatch_lines(["* 1 passed in *"]) |
| 1440 | |
| 1441 | def setup_conftest_and_foo(self, pytester: Pytester) -> None: |
| 1442 | """Setup a tests folder to be used to test if modules in that folder can be imported |
nothing calls this directly
no test coverage detected