Fix the ImportWarning regarding __spec__ and __package__ being None (GH-16003)
(cherry picked from commit 6e1a30b15e
)
Co-authored-by: Xtreak <tir.karthi@gmail.com>
This commit is contained in:
parent
8750dfe09e
commit
52c99aeb9f
|
@ -161,9 +161,10 @@ class BuiltinTest(unittest.TestCase):
|
||||||
self.assertRaises(ValueError, __import__, '')
|
self.assertRaises(ValueError, __import__, '')
|
||||||
self.assertRaises(TypeError, __import__, 'sys', name='sys')
|
self.assertRaises(TypeError, __import__, 'sys', name='sys')
|
||||||
# Relative import outside of a package with no __package__ or __spec__ (bpo-37409).
|
# Relative import outside of a package with no __package__ or __spec__ (bpo-37409).
|
||||||
self.assertRaises(ImportError, __import__, '',
|
with self.assertWarns(ImportWarning):
|
||||||
{'__package__': None, '__spec__': None, '__name__': '__main__'},
|
self.assertRaises(ImportError, __import__, '',
|
||||||
locals={}, fromlist=('foo',), level=1)
|
{'__package__': None, '__spec__': None, '__name__': '__main__'},
|
||||||
|
locals={}, fromlist=('foo',), level=1)
|
||||||
# embedded null character
|
# embedded null character
|
||||||
self.assertRaises(ModuleNotFoundError, __import__, 'string\x00')
|
self.assertRaises(ModuleNotFoundError, __import__, 'string\x00')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue