]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-69605: In test_pyrepl.test_already_imported*, invalidate FS import caches (#143436)
authorŁukasz Langa <lukasz@langa.pl>
Mon, 5 Jan 2026 17:00:48 +0000 (18:00 +0100)
committerGitHub <noreply@github.com>
Mon, 5 Jan 2026 17:00:48 +0000 (18:00 +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 961787b6f9058b18eadfb4b58aacd44b1cc96cf7..baf03ef6cd95eebc872094f88ac068305b0e1633 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":