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)