##// END OF EJS Templates
Merge pull request #11227 from yen223/11226-3-7-autocomplete-bugfix...
Matthias Bussonnier -
r24422:134f9705 merge
parent child Browse files
Show More
@@ -165,7 +165,7 b' def try_import(mod: str, only_modules=False) -> List[str]:'
165 165 except:
166 166 return []
167 167
168 m_is_init = hasattr(m, '__file__') and '__init__' in m.__file__
168 m_is_init = '__init__' in (getattr(m, '__file__', '') or '')
169 169
170 170 completions = []
171 171 if (not hasattr(m, '__file__')) or (not only_modules) or m_is_init:
@@ -16,7 +16,7 b' from os.path import join'
16 16
17 17 import nose.tools as nt
18 18
19 from IPython.core.completerlib import magic_run_completer, module_completion
19 from IPython.core.completerlib import magic_run_completer, module_completion, try_import
20 20 from IPython.utils.tempdir import TemporaryDirectory
21 21 from IPython.testing.decorators import onlyif_unicode_paths
22 22
@@ -159,3 +159,20 b' def test_bad_module_all():'
159 159 nt.assert_is_instance(r, str)
160 160 finally:
161 161 sys.path.remove(testsdir)
162
163
164 def test_module_without_init():
165 """
166 Test module without __init__.py.
167
168 https://github.com/ipython/ipython/issues/11226
169 """
170 fake_module_name = "foo"
171 with TemporaryDirectory() as tmpdir:
172 sys.path.insert(0, tmpdir)
173 try:
174 os.makedirs(os.path.join(tmpdir, fake_module_name))
175 s = try_import(mod=fake_module_name)
176 assert s == []
177 finally:
178 sys.path.remove(tmpdir)
General Comments 0
You need to be logged in to leave comments. Login now