From c7f28a4db6af25eb59d218f51fa3e7d57eaeb1a7 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Thu, 26 Dec 2024 10:31:56 +0100 Subject: [PATCH] Make sure that patching is correctly stopped - add more hooks to ensure pause/resume for module and session scoped fs fixtures --- .github/workflows/testsuite.yml | 4 ---- CHANGES.md | 6 ++++++ pyfakefs/pytest_plugin.py | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index 0fbdec73..8c575e1f 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -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 }} diff --git a/CHANGES.md b/CHANGES.md index 15ccb5b6..951d2e54 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/pyfakefs/pytest_plugin.py b/pyfakefs/pytest_plugin.py index 223ef2d4..16775000 100644 --- a/pyfakefs/pytest_plugin.py +++ b/pyfakefs/pytest_plugin.py @@ -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