Skip to content

Commit bf112c3

Browse files
committed
Autouse-pytester in test_pathlib
1 parent c9ce821 commit bf112c3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

testing/test_pathlib.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
import pytest
3636

3737

38+
@pytest.fixture(autouse=True)
39+
def autouse_pytester(pytester: Pytester) -> None:
40+
"""
41+
Fixture to make pytester() being autouse for all tests in this module.
42+
43+
pytester makes sure to restore sys.path to its previous state, and many tests in this module
44+
import modules and change sys.path because of that, so common module names such as "test" or "test.conftest"
45+
end up leaking to tests in other modules.
46+
47+
Note: we might consider extracting the sys.path restoration aspect into its own fixture, and apply it
48+
to the entire test suite always.
49+
"""
50+
51+
3852
class TestFNMatcherPort:
3953
"""Test our port of py.common.FNMatcher (fnmatch_ex)."""
4054

0 commit comments

Comments
 (0)