MCPcopy Index your code
hub / github.com/ipython/ipython / test_import_invalid_module

Function test_import_invalid_module

tests/test_completerlib.py:133–147  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

module_completionFunction · 0.90
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…