Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-69605: Disable PyREPL module autocomplete fallback on regular completion #134181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 25, 2025
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
Tests: mock sys.path in setUp instead
  • Loading branch information
Loïc Simon committed May 20, 2025
commit 84c4f765bde1ff500f5218281b7b60cd4d707d26
18 changes: 7 additions & 11 deletions 18 Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,14 @@ def test_func(self):

class TestPyReplModuleCompleter(TestCase):
def setUp(self):
import importlib
# Make iter_modules() search only the standard library.
# This makes the test more reliable in case there are
# other user packages/scripts on PYTHONPATH which can
# interfere with the completions.
lib_path = os.path.dirname(importlib.__path__[0])
self._saved_sys_path = sys.path
sys.path = [lib_path]

def tearDown(self):
sys.path = self._saved_sys_path
Expand All @@ -929,17 +936,7 @@ def prepare_reader(self, events, namespace):
reader = ReadlineAlikeReader(console=console, config=config)
return reader

def _only_stdlib_imports(self):
import importlib
# Make iter_modules() search only the standard library.
# This makes the test more reliable in case there are
# other user packages/scripts on PYTHONPATH which can
# intefere with the completions.
lib_path = os.path.dirname(importlib.__path__[0])
sys.path = [lib_path]

def test_import_completions(self):
self._only_stdlib_imports()
cases = (
("import path\t\n", "import pathlib"),
("import importlib.\t\tres\t\n", "import importlib.resources"),
Expand Down Expand Up @@ -991,7 +988,6 @@ def test_invalid_identifiers(self):
self.assertEqual(output, expected)

def test_no_fallback_on_regular_completion(self):
self._only_stdlib_imports()
cases = (
("import pri\t\n", "import pri"),
("from pri\t\n", "from pri"),
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.