Skip to content

Commit

Permalink
Exclude pytest pathlib module from patching (#828)
Browse files Browse the repository at this point in the history
- fixes some specific tests in namespace packages
- fixes #814
  • Loading branch information
mrbean-bremen authored May 17, 2023
1 parent 2a3a11c commit f6e76bb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ jobs:
run: |
echo "$(python -m pytest pyfakefs/pytest_tests/pytest_plugin_failing_helper.py)" > ./testresult.txt
python -m pytest pyfakefs/pytest_tests
if [[ '${{ matrix.pytest-version }}' > '3.0.0' ]]; then
cd pyfakefs/pytest_tests/ns_package
python -m pytest --log-cli-level=INFO test
fi
shell: bash

dependency-check:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The released versions correspond to PyPI releases.
### Fixes
* Re-create temp directory if it had been created before on resetting file system
(see [#814](../../issues/814)).
* Exclude pytest `pathlib` modules from patching to avoid mixup of patched/unpatched
code (see [#814](../../issues/814)).

### Infrastructure
* Added pytype check for non-test modules in CI (see [#599](../../issues/599)).
Expand Down
7 changes: 7 additions & 0 deletions pyfakefs/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ def my_fakefs_test(fs):

from pyfakefs.fake_filesystem_unittest import Patcher

try:
from _pytest import pathlib
except ImportError:
pathlib = None

Patcher.SKIPMODULES.add(py)
Patcher.SKIPMODULES.add(pytest)
if pathlib is not None:
Patcher.SKIPMODULES.add(pathlib)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pyfakefs.fake_filesystem


def test_foo(fs):
"""Regression test for #814 - must run in namespace package with cli logging."""
fs.os = pyfakefs.fake_filesystem.OSType.WINDOWS
assert True
Empty file.

0 comments on commit f6e76bb

Please sign in to comment.