Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the tests more robust
  • Loading branch information
tomasr8 committed Apr 17, 2025
commit 8eb656f7a1942c8652338447464e5914be01602d
12 changes: 11 additions & 1 deletion Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import tempfile
from unittest import TestCase, skipUnless, skipIf
from unittest.mock import patch
from test.support import force_not_colorized, make_clean_env
from test.support import force_not_colorized, make_clean_env, patch_list
from test.support import SHORT_TIMEOUT
from test.support.import_helper import import_module
from test.support.os_helper import unlink
Expand Down Expand Up @@ -904,7 +904,17 @@ def prepare_reader(self, events, namespace):
reader = ReadlineAlikeReader(console=console, config=config)
return reader

@patch_list(sys.meta_path)
def test_import_completions(self):
from importlib.machinery import BuiltinImporter
# Remove all importers except for the builtin one
# to prevent searching anything but the builtin modules.
# This makes the test more reliable in case there are
# other user packages/scripts on PYTHONPATH which can
# intefere with the completions.
sys.meta_path = [finder for finder in sys.meta_path
if isinstance(finder, BuiltinImporter)]

cases = (
("import path\t\n", "import pathlib"),
("import importlib.\t\tres\t\n", "import importlib.resources"),
Expand Down
Loading