From 2ebf3b821393558189be22c45f36de16e8f68bc0 2018-07-14 06:18:43 From: Wei Yen Date: 2018-07-14 06:18:43 Subject: [PATCH] Add regression test There's a bug in try_import that will cause this test to raise an "NoneType has no attribute" exception. --- diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py index 6e2a540..af13c02 100644 --- a/IPython/core/tests/test_completerlib.py +++ b/IPython/core/tests/test_completerlib.py @@ -16,7 +16,7 @@ from os.path import join import nose.tools as nt -from IPython.core.completerlib import magic_run_completer, module_completion +from IPython.core.completerlib import magic_run_completer, module_completion, try_import from IPython.utils.tempdir import TemporaryDirectory from IPython.testing.decorators import onlyif_unicode_paths @@ -159,3 +159,17 @@ def test_bad_module_all(): nt.assert_is_instance(r, str) finally: sys.path.remove(testsdir) + + +def test_module_without_init(): + """ + Test module without __init__.py. + + https://github.com/ipython/ipython/issues/11226 + """ + fake_module_name = "foo" + with TemporaryDirectory() as tmpdir: + sys.path.insert(0, tmpdir) + os.makedirs(os.path.join(tmpdir, fake_module_name)) + s = try_import(mod=fake_module_name) + assert s == []