mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.14] gh-134235: Import Autocomplete for Builtin Modules (GH-134277) (#134285)
gh-134235: Import Autocomplete for Builtin Modules (GH-134277)
* added enhancement auto completing import with sys builtins
---------
(cherry picked from commit 8421b03b16
)
Co-authored-by: Tom Wang <85062819+tommix626@users.noreply.github.com>
Co-authored-by: Hunter <hyoung3@gmail.com>
This commit is contained in:
parent
7686c752b3
commit
7cbc3ea8fb
3 changed files with 25 additions and 2 deletions
|
@ -959,6 +959,26 @@ class TestPyReplModuleCompleter(TestCase):
|
|||
output = reader.readline()
|
||||
self.assertEqual(output, expected)
|
||||
|
||||
def test_builtin_completion_top_level(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]
|
||||
|
||||
cases = (
|
||||
("import bui\t\n", "import builtins"),
|
||||
("from bui\t\n", "from builtins"),
|
||||
)
|
||||
for code, expected in cases:
|
||||
with self.subTest(code=code):
|
||||
events = code_to_events(code)
|
||||
reader = self.prepare_reader(events, namespace={})
|
||||
output = reader.readline()
|
||||
self.assertEqual(output, expected)
|
||||
|
||||
def test_relative_import_completions(self):
|
||||
cases = (
|
||||
("from .readl\t\n", "from .readline"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue