Skip to content

Commit 306d9e0

Browse files
committed
Autouse-pytester in test_pathlib
1 parent 2a7aca9 commit 306d9e0

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
@@ -37,6 +37,20 @@
3737
import pytest
3838

3939

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

0 commit comments

Comments
 (0)