diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-09-12 09:29:36 (GMT) |
---|---|---|
committer | Brett Cannon <54418+brettcannon@users.noreply.github.com> | 2019-09-12 09:29:36 (GMT) |
commit | 6e1a30b15e73ebc82e6790495fd54cc8971723ec (patch) | |
tree | 96df50c1aa3fe33200ab15872350726118702157 /Lib/test/test_builtin.py | |
parent | 8ed6503eca4e3ea4949479d8d7fd9ffd54f81038 (diff) | |
download | cpython-6e1a30b15e73ebc82e6790495fd54cc8971723ec.zip cpython-6e1a30b15e73ebc82e6790495fd54cc8971723ec.tar.gz cpython-6e1a30b15e73ebc82e6790495fd54cc8971723ec.tar.bz2 |
Fix the ImportWarning regarding __spec__ and __package__ being None (GH-16003)
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 185d8f7..e1d2fff 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -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') |