Kaydet (Commit) c5951fc9 authored tarafından Brett Cannon's avatar Brett Cannon

Make __package__ setting tests specific to importlib. Also move to assertRaises context manager.

üst 6d2bb7f5
......@@ -56,15 +56,16 @@ class Using__package__(unittest.TestCase):
def test_bad__package__(self):
globals = {'__package__': '<not real>'}
self.assertRaises(SystemError, import_util.import_,'', globals, {},
['relimport'], 1)
with self.assertRaises(SystemError):
import_util.import_('', globals, {}, ['relimport'], 1)
def test_bunk__package__(self):
globals = {'__package__': 42}
self.assertRaises(ValueError, import_util.import_, '', globals, {},
['relimport'], 1)
with self.assertRaises(ValueError):
import_util.import_('', globals, {}, ['relimport'], 1)
@import_util.importlib_only
class Setting__package__(unittest.TestCase):
"""Because __package__ is a new feature, it is not always set by a loader.
......
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