Commit c5951fc9 authored by Brett Cannon's avatar Brett Cannon

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

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