Skip to content

Commit f6e76bb

Browse files
Exclude pytest pathlib module from patching (#828)
- fixes some specific tests in namespace packages - fixes #814
1 parent 2a3a11c commit f6e76bb

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

.github/workflows/testsuite.yml

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ jobs:
116116
run: |
117117
echo "$(python -m pytest pyfakefs/pytest_tests/pytest_plugin_failing_helper.py)" > ./testresult.txt
118118
python -m pytest pyfakefs/pytest_tests
119+
if [[ '${{ matrix.pytest-version }}' > '3.0.0' ]]; then
120+
cd pyfakefs/pytest_tests/ns_package
121+
python -m pytest --log-cli-level=INFO test
122+
fi
119123
shell: bash
120124

121125
dependency-check:

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The released versions correspond to PyPI releases.
66
### Fixes
77
* Re-create temp directory if it had been created before on resetting file system
88
(see [#814](../../issues/814)).
9+
* Exclude pytest `pathlib` modules from patching to avoid mixup of patched/unpatched
10+
code (see [#814](../../issues/814)).
911

1012
### Infrastructure
1113
* Added pytype check for non-test modules in CI (see [#599](../../issues/599)).

pyfakefs/pytest_plugin.py

+7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@ def my_fakefs_test(fs):
1313

1414
from pyfakefs.fake_filesystem_unittest import Patcher
1515

16+
try:
17+
from _pytest import pathlib
18+
except ImportError:
19+
pathlib = None
20+
1621
Patcher.SKIPMODULES.add(py)
1722
Patcher.SKIPMODULES.add(pytest)
23+
if pathlib is not None:
24+
Patcher.SKIPMODULES.add(pathlib)
1825

1926

2027
@pytest.fixture
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import pyfakefs.fake_filesystem
2+
3+
4+
def test_foo(fs):
5+
"""Regression test for #814 - must run in namespace package with cli logging."""
6+
fs.os = pyfakefs.fake_filesystem.OSType.WINDOWS
7+
assert True

pyfakefs/pytest_tests/ns_package/test/setup.py

Whitespace-only changes.

0 commit comments

Comments
 (0)