]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-69605: In test_pyrepl.test_already_imported*, invalidate FS import caches (#143436) 143438/head
authorŁukasz Langa <lukasz@langa.pl>
Mon, 5 Jan 2026 17:00:48 +0000 (18:00 +0100)
committerŁukasz Langa <lukasz@langa.pl>
Mon, 5 Jan 2026 17:13:56 +0000 (18:13 +0100)
This makes the test robust against file systems with low timestamp resolution, which otherwise would fail to re-import in the tight loop of the test.

Lib/test/test_pyrepl/test_pyrepl.py

index d0ad960219b5947f67912b15fdf6dfecc58d8af9..b1c6e5c99696dae2b305690e05e834a02402f01a 100644 (file)
@@ -1192,6 +1192,7 @@ class TestPyReplModuleCompleter(TestCase):
                 (dir1 / mod).mkdir()
                 (dir1 / mod / "__init__.py").touch()
                 (dir1 / mod / "foo.py").touch()
+                pkgutil.get_importer(_dir1).invalidate_caches()
                 module = importlib.import_module(mod)
                 assert module.__spec__
                 if mod == "no_origin":