From 4d6494b58afd1642b787833ed5ae9230dd3c4d6d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 13 Aug 2026 18:17:48 +0300 Subject: [PATCH] gh-155727: Ignore internal imports in test_attribute_completion Reader.run_hooks() imports _pyrepl._threading_handler lazily, and the test counted it as a module imported by the completer. --- Lib/test/test_pyrepl/test_pyrepl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 04a7a1b7f56751e..7cc178f19df6f9d 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -1467,7 +1467,10 @@ def test_attribute_completion(self): reader = self.prepare_reader(events, namespace={}) output = reader.readline() self.assertEqual(output, expected) - new_imports = sys.modules.keys() - _imported + # The reader imports its own helpers lazily. + new_imports = {name for name in + sys.modules.keys() - _imported + if not name.startswith('_pyrepl.')} self.assertEqual(new_imports, expected_imports) @patch.dict(sys.modules)