Skip to content

Commit

Permalink
Make sure that patching is correctly stopped
Browse files Browse the repository at this point in the history
- add more hooks to ensure pause/resume for module
  and session scoped fs fixtures
  • Loading branch information
mrbean-bremen committed Dec 26, 2024
1 parent 6d0d3c6 commit 6ab490b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
pytest-version: [6.2.5, 7.0.1, 7.4.4, 8.0.2, 8.3.4]
exclude:
# some tests still fail for macOS/Python 3.13
- python-version: "3.13"
os: macOS-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ The released versions correspond to PyPI releases.
* the default for `FakeFilesystem.shuffle_listdir_results` will change to `True` to reflect
the real filesystem behavior

## Unreleased

### Fixes
* fixed a problem with module and session scoped fixtures in Python 3.13
(see [#1101](../../issues/1101))

## [Version 5.7.3](https://pypi.python.org/pypi/pyfakefs/5.7.3) (2024-12-15)
Fixes a regression in version 5.7.3.

Expand Down
15 changes: 14 additions & 1 deletion pyfakefs/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,18 @@ def pytest_runtest_logreport(report):
if pause:
Patcher.PATCHER.pause()
yield
if pause:


@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_runtest_call(item):
if Patcher.PATCHER is not None:
Patcher.PATCHER.resume()
yield


@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_teardown(item, nextitem):
"""Make sure that patching is not active during reporting."""
if Patcher.PATCHER is not None:
Patcher.PATCHER.pause()
yield

0 comments on commit 6ab490b

Please sign in to comment.