Skip to content

Commit 10b585c

Browse files
committed
Add coverage.python to skipped modules
- consider skipped modules for fake `open`
1 parent ce8b467 commit 10b585c

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ The released versions correspond to PyPI releases.
2020
### Fixes
2121
* fixes a problem with `Path` type hints using the pipe symbol in wrapped functions
2222
inside an `fs` dependent fixture (see [#1242](../../issues/1242))
23+
* fixes problem with new `coverage` in Python 3.14 using the fake filesystem
24+
(see [#1245](../../issues/1245))
2325

2426
## [Version 5.10.2](https://pypi.python.org/pypi/pyfakefs/5.10.2) (2025-11-04)
2527
Fixes a problem with `pathlib.glob` in Python 3.14.

pyfakefs/fake_filesystem_unittest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,12 @@ def _refresh(self) -> None:
10121012
for name in self._fake_module_classes:
10131013
self.fake_modules[name] = self._fake_module_classes[name](self.fs)
10141014
if hasattr(self.fake_modules[name], "skip_names"):
1015-
self.fake_modules[name].skip_names = self.skip_names
1015+
self.fake_modules[name].skip_names = self.skip_names | {
1016+
# also skip non-build-in skipped modules
1017+
m.__name__
1018+
for m in self.SKIPMODULES
1019+
if m and "." in m.__name__
1020+
}
10161021
self.fake_modules[PATH_MODULE] = self.fake_modules["os"].path
10171022
for name in self._unfaked_module_classes:
10181023
self.unfaked_modules[name] = self._unfaked_module_classes[name]()

pyfakefs/pytest_plugin.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ def my_fakefs_test(fs):
1919

2020
try:
2121
from _pytest import pathlib
22+
23+
Patcher.SKIPMODULES.add(pathlib)
2224
except ImportError:
23-
pathlib = None # type:ignore[assignment]
25+
pass
26+
27+
try:
28+
from coverage import python # type:ignore[import]
29+
30+
Patcher.SKIPMODULES.add(python)
31+
except ImportError:
32+
pass
2433

2534
Patcher.SKIPMODULES.add(py)
2635
Patcher.SKIPMODULES.add(pytest)
2736
Patcher.SKIPMODULES.add(capture)
28-
if pathlib is not None:
29-
Patcher.SKIPMODULES.add(pathlib)
3037

3138

3239
@pytest.fixture

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ xdist = [
7373

7474
[tool.setuptools]
7575
include-package-data = true
76+
py-modules = ["pyfakefs"]
7677

7778
[tool.setuptools.package-data]
7879
where = ["pyfakefs"]

0 commit comments

Comments
 (0)