MCPcopy Create free account
hub / github.com/ipython/ipython / test_import_invalid_module

Function test_import_invalid_module

IPython/core/tests/test_completerlib.py:131–145  ·  view source on GitHub ↗

Testing of issue https://github.com/ipython/ipython/issues/1107

()

Source from the content-addressed store, hash-verified

129# module_completer:
130
131def test_import_invalid_module():
132 """Testing of issue https://github.com/ipython/ipython/issues/1107"""
133 invalid_module_names = {'foo-bar', 'foo:bar', '10foo'}
134 valid_module_names = {'foobar'}
135 with TemporaryDirectory() as tmpdir:
136 sys.path.insert( 0, tmpdir )
137 for name in invalid_module_names | valid_module_names:
138 filename = os.path.join(tmpdir, name + '.py')
139 open(filename, 'w').close()
140
141 s = set( module_completion('import foo') )
142 intersection = s.intersection(invalid_module_names)
143 nt.assert_equal(intersection, set())
144
145 assert valid_module_names.issubset(s), valid_module_names.intersection(s)
146
147
148def test_bad_module_all():

Callers

nothing calls this directly

Calls 2

module_completionFunction · 0.90
closeMethod · 0.45

Tested by

no test coverage detected