From 14eb9904c97083869eb7dd6c1c8600c056502730 2012-02-28 20:07:23 From: Ross Jones Date: 2012-02-28 20:07:23 Subject: [PATCH] Failing tests for https://github.com/ipython/ipython/issues/1107 --- diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py index d50c122..b442eb9 100644 --- a/IPython/core/tests/test_completerlib.py +++ b/IPython/core/tests/test_completerlib.py @@ -18,8 +18,9 @@ from os.path import join import nose.tools as nt from nose import SkipTest -from IPython.core.completerlib import magic_run_completer +from IPython.core.completerlib import magic_run_completer, module_completion from IPython.utils import py3compat +from IPython.utils.tempdir import TemporaryDirectory class MockEvent(object): @@ -65,3 +66,14 @@ class Test_magic_run_completer(unittest.TestCase): match = set(magic_run_completer(mockself, event)) self.assertEqual(match, set([u"a.py", u"aaø.py"])) + def test_import_invalid_module(self): + """Testing of issue https://github.com/ipython/ipython/issues/1107""" + invalid_module_names = set(['foo-bar', 'foo:bar', '10foo']) + with TemporaryDirectory() as tmpdir: + sys.path.insert( 0, tmpdir ) + for name in invalid_module_names: + filename = os.path.join(tmpdir, name + '.py') + open(filename, 'w').close() + + s = set( module_completion('import foo') ) + self.assertFalse( s.intersection(invalid_module_names) )