Commit 6e1a30b1 authored by Xtreak's avatar Xtreak Committed by Brett Cannon

Fix the ImportWarning regarding __spec__ and __package__ being None (GH-16003)

parent 8ed6503e
......@@ -161,9 +161,10 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(ValueError, __import__, '')
self.assertRaises(TypeError, __import__, 'sys', name='sys')
# Relative import outside of a package with no __package__ or __spec__ (bpo-37409).
self.assertRaises(ImportError, __import__, '',
{'__package__': None, '__spec__': None, '__name__': '__main__'},
locals={}, fromlist=('foo',), level=1)
with self.assertWarns(ImportWarning):
self.assertRaises(ImportError, __import__, '',
{'__package__': None, '__spec__': None, '__name__': '__main__'},
locals={}, fromlist=('foo',), level=1)
# embedded null character
self.assertRaises(ModuleNotFoundError, __import__, 'string\x00')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment