]> granicus.if.org Git - python/commitdiff
Make __package__ setting tests specific to importlib. Also move to assertRaises conte...
authorBrett Cannon <bcannon@gmail.com>
Thu, 27 Aug 2009 23:46:38 +0000 (23:46 +0000)
committerBrett Cannon <bcannon@gmail.com>
Thu, 27 Aug 2009 23:46:38 +0000 (23:46 +0000)
Lib/importlib/test/import_/test___package__.py

index 2aa0814092192ba2cd1bc1997e892f6e8dc3894d..4eb1f856b1363a0b7a318889ef8dd782d34593a7 100644 (file)
@@ -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.