Show More
@@ -223,7 +223,7 b' def module_completion(line):' | |||||
223 | return ['import '] |
|
223 | return ['import '] | |
224 |
|
224 | |||
225 | # 'from xy<tab>' or 'import xy<tab>' |
|
225 | # 'from xy<tab>' or 'import xy<tab>' | |
226 |
if nwords < 3 and (words[0] in |
|
226 | if nwords < 3 and (words[0] in {'%aimport', 'import', 'from'}) : | |
227 | if nwords == 1: |
|
227 | if nwords == 1: | |
228 | return get_root_modules() |
|
228 | return get_root_modules() | |
229 | mod = words[1].split('.') |
|
229 | mod = words[1].split('.') |
@@ -2103,6 +2103,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2103 |
|
2103 | |||
2104 | self.set_hook('complete_command', module_completer, str_key = 'import') |
|
2104 | self.set_hook('complete_command', module_completer, str_key = 'import') | |
2105 | self.set_hook('complete_command', module_completer, str_key = 'from') |
|
2105 | self.set_hook('complete_command', module_completer, str_key = 'from') | |
|
2106 | self.set_hook('complete_command', module_completer, str_key = '%aimport') | |||
2106 | self.set_hook('complete_command', magic_run_completer, str_key = '%run') |
|
2107 | self.set_hook('complete_command', magic_run_completer, str_key = '%run') | |
2107 | self.set_hook('complete_command', cd_completer, str_key = '%cd') |
|
2108 | self.set_hook('complete_command', cd_completer, str_key = '%cd') | |
2108 | self.set_hook('complete_command', reset_completer, str_key = '%reset') |
|
2109 | self.set_hook('complete_command', reset_completer, str_key = '%reset') |
@@ -13,11 +13,11 b' from contextlib import contextmanager' | |||||
13 | import nose.tools as nt |
|
13 | import nose.tools as nt | |
14 |
|
14 | |||
15 | from traitlets.config.loader import Config |
|
15 | from traitlets.config.loader import Config | |
|
16 | from IPython import get_ipython | |||
16 | from IPython.core import completer |
|
17 | from IPython.core import completer | |
17 | from IPython.external.decorators import knownfailureif |
|
18 | from IPython.external.decorators import knownfailureif | |
18 | from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory |
|
19 | from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory | |
19 | from IPython.utils.generics import complete_object |
|
20 | from IPython.utils.generics import complete_object | |
20 | from IPython.utils import py3compat |
|
|||
21 | from IPython.utils.py3compat import string_types, unicode_type |
|
21 | from IPython.utils.py3compat import string_types, unicode_type | |
22 | from IPython.testing import decorators as dec |
|
22 | from IPython.testing import decorators as dec | |
23 |
|
23 | |||
@@ -760,3 +760,21 b' def test_dict_key_completion_invalids():' | |||||
760 | _, matches = complete(line_buffer="empty['") |
|
760 | _, matches = complete(line_buffer="empty['") | |
761 | _, matches = complete(line_buffer="name_error['") |
|
761 | _, matches = complete(line_buffer="name_error['") | |
762 | _, matches = complete(line_buffer="d['\\") # incomplete escape |
|
762 | _, matches = complete(line_buffer="d['\\") # incomplete escape | |
|
763 | ||||
|
764 | def test_aimport_module_completer(): | |||
|
765 | ip = get_ipython() | |||
|
766 | _, matches = ip.complete('i', '%aimport i') | |||
|
767 | nt.assert_in('io', matches) | |||
|
768 | nt.assert_not_in('int', matches) | |||
|
769 | ||||
|
770 | def test_import_module_completer(): | |||
|
771 | ip = get_ipython() | |||
|
772 | _, matches = ip.complete('i', 'import i') | |||
|
773 | nt.assert_in('io', matches) | |||
|
774 | nt.assert_not_in('int', matches) | |||
|
775 | ||||
|
776 | def test_from_module_completer(): | |||
|
777 | ip = get_ipython() | |||
|
778 | _, matches = ip.complete('B', 'from io import B') | |||
|
779 | nt.assert_in('BytesIO', matches) | |||
|
780 | nt.assert_not_in('BaseException', matches) |
General Comments 0
You need to be logged in to leave comments.
Login now