##// END OF EJS Templates
Test that valid local module names are found for import completions.
Thomas Kluyver -
Show More
@@ -69,12 +69,15 b' class Test_magic_run_completer(unittest.TestCase):'
69 def test_import_invalid_module(self):
69 def test_import_invalid_module(self):
70 """Testing of issue https://github.com/ipython/ipython/issues/1107"""
70 """Testing of issue https://github.com/ipython/ipython/issues/1107"""
71 invalid_module_names = set(['foo-bar', 'foo:bar', '10foo'])
71 invalid_module_names = set(['foo-bar', 'foo:bar', '10foo'])
72 valid_module_names = set(['foobar'])
72 with TemporaryDirectory() as tmpdir:
73 with TemporaryDirectory() as tmpdir:
73 sys.path.insert( 0, tmpdir )
74 sys.path.insert( 0, tmpdir )
74 for name in invalid_module_names:
75 for name in invalid_module_names | valid_module_names:
75 filename = os.path.join(tmpdir, name + '.py')
76 filename = os.path.join(tmpdir, name + '.py')
76 open(filename, 'w').close()
77 open(filename, 'w').close()
77
78
78 s = set( module_completion('import foo') )
79 s = set( module_completion('import foo') )
79 intersection = s.intersection(invalid_module_names)
80 intersection = s.intersection(invalid_module_names)
80 self.assertFalse(intersection, intersection)
81 self.assertFalse(intersection, intersection)
82
83 assert valid_module_names.issubset(s), valid_module_names.intersection(s)
General Comments 0
You need to be logged in to leave comments. Login now