diff --git a/CHANGES.md b/CHANGES.md index 521fb7cc..18673032 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 regression in version 5.7.2 that `tempfile` was not patched after pause/resume + (POSIX only, see [#1098](../../issues/1098)) + ## [Version 5.7.2](https://pypi.python.org/pypi/pyfakefs/5.7.2) (2024-12-01) Fixes some problems with patching. diff --git a/pyfakefs/fake_filesystem_unittest.py b/pyfakefs/fake_filesystem_unittest.py index f272cefd..7730df2d 100644 --- a/pyfakefs/fake_filesystem_unittest.py +++ b/pyfakefs/fake_filesystem_unittest.py @@ -125,6 +125,7 @@ def stop_patching(self): tempfile._TemporaryFileCloser.close = self.tempfile_cleanup # type: ignore[module-attr] else: tempfile._TemporaryFileCloser.cleanup = self.tempfile_cleanup # type: ignore[module-attr] + self.tempfile_cleanup = None # reset the cached tempdir in tempfile tempfile.tempdir = None diff --git a/pyfakefs/tests/fake_filesystem_unittest_test.py b/pyfakefs/tests/fake_filesystem_unittest_test.py index 99ac9636..ff571d62 100644 --- a/pyfakefs/tests/fake_filesystem_unittest_test.py +++ b/pyfakefs/tests/fake_filesystem_unittest_test.py @@ -639,6 +639,13 @@ def test_pause_resume_without_patcher(self): with self.assertRaises(RuntimeError): fs.resume() + def test_that_tempfile_is_patched_after_resume(fs): + """Regression test for #1098""" + fs.pause() + fs.resume() + with tempfile.NamedTemporaryFile(): + pass + class PauseResumePatcherTest(fake_filesystem_unittest.TestCase): def test_pause_resume(self):