diff options
Diffstat (limited to 'Lib/importlib/test/source/test_file_loader.py')
-rw-r--r-- | Lib/importlib/test/source/test_file_loader.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py index 0384e7d88c7..b18750c2a38 100644 --- a/Lib/importlib/test/source/test_file_loader.py +++ b/Lib/importlib/test/source/test_file_loader.py @@ -93,7 +93,8 @@ class SimpleTest(unittest.TestCase): file.write('+++ bad syntax +++') loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'], False) - self.assertRaises(SyntaxError, loader.load_module, name) + with self.assertRaises(SyntaxError): + loader.load_module(name) for attr in attributes: self.assertEqual(getattr(orig_module, attr), value) @@ -104,7 +105,8 @@ class SimpleTest(unittest.TestCase): file.write('=') loader = _bootstrap._PyPycFileLoader('_temp', mapping['_temp'], False) - self.assertRaises(SyntaxError, loader.load_module, '_temp') + with self.assertRaises(SyntaxError): + loader.load_module('_temp') self.assertTrue('_temp' not in sys.modules) @@ -166,8 +168,8 @@ class BadBytecodeTest(unittest.TestCase): bytecode_file.write(imp.get_magic()) bytecode_file.write(source_timestamp) bytecode_file.write(b'AAAA') - self.assertRaises(ValueError, self.import_, mapping['_temp'], - '_temp') + with self.assertRaises(ValueError): + self.import_(mapping['_temp'], '_temp') self.assertTrue('_temp' not in sys.modules) |