MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_import

Method test_import

Lib/test/test_builtin.py:173–189  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

171 self.assertEqual(list(it), seq[1:])
172
173 def test_import(self):
174 __import__('sys')
175 __import__('time')
176 __import__('string')
177 __import__(name='sys')
178 __import__(name='time', level=0)
179 self.assertRaises(ModuleNotFoundError, __import__, 'spamspam')
180 self.assertRaises(TypeError, __import__, 1, 2, 3, 4)
181 self.assertRaises(ValueError, __import__, '')
182 self.assertRaises(TypeError, __import__, 'sys', name='sys')
183 # Relative import outside of a package with no __package__ or __spec__ (bpo-37409).
184 with self.assertWarns(ImportWarning):
185 self.assertRaises(ImportError, __import__, '',
186 {'__package__': None, '__spec__': None, '__name__': '__main__'},
187 locals={}, fromlist=('foo',), level=1)
188 # embedded null character
189 self.assertRaises(ModuleNotFoundError, __import__, 'string\x00')
190
191 def test_abs(self):
192 # int

Callers

nothing calls this directly

Calls 3

assertWarnsMethod · 0.80
__import__Function · 0.50
assertRaisesMethod · 0.45

Tested by

no test coverage detected