[Python-checkins] Fix the ImportWarning regarding __spec__ and __package__ being None (GH-16003)
Brett Cannon
webhook-mailer at python.org
Thu Sep 12 05:29:40 EDT 2019
https://github.com/python/cpython/commit/6e1a30b15e73ebc82e6790495fd54cc8971723ec
commit: 6e1a30b15e73ebc82e6790495fd54cc8971723ec
branch: master
author: Xtreak <tir.karthi at gmail.com>
committer: Brett Cannon <54418+brettcannon at users.noreply.github.com>
date: 2019-09-12T10:29:36+01:00
summary:
Fix the ImportWarning regarding __spec__ and __package__ being None (GH-16003)
files:
M Lib/test/test_builtin.py
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 185d8f794b25..e1d2fffb36ea 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -161,9 +161,10 @@ def test_import(self):
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')
More information about the Python-checkins
mailing list