aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/importlib/test/source/test_file_loader.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-08-27 23:49:21 +0000
committerBrett Cannon <bcannon@gmail.com>2009-08-27 23:49:21 +0000
commit2153dc001f5565592b44808d7f0f25815010eb9d (patch)
tree8801111b4467bd21f5f936d3fd6196d41f77688f /Lib/importlib/test/source/test_file_loader.py
parentc5951fc996ad74a05e83a61cf0345a4a68c01b12 (diff)
downloadcpython-2153dc001f5565592b44808d7f0f25815010eb9d.tar.gz
cpython-2153dc001f5565592b44808d7f0f25815010eb9d.zip
Move over to using assertRaises as a context manager for importlib tests.
Obviously one shouldn't do whole sale conversions like this, but I was already going through the test code and I was bored at the airport.
Diffstat (limited to 'Lib/importlib/test/source/test_file_loader.py')
-rw-r--r--Lib/importlib/test/source/test_file_loader.py10
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)