diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-08-27 23:49:21 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-08-27 23:49:21 (GMT) |
commit | 2153dc001f5565592b44808d7f0f25815010eb9d (patch) | |
tree | 8801111b4467bd21f5f936d3fd6196d41f77688f /Lib/importlib/test/builtin/test_loader.py | |
parent | c5951fc996ad74a05e83a61cf0345a4a68c01b12 (diff) | |
download | cpython-2153dc001f5565592b44808d7f0f25815010eb9d.zip cpython-2153dc001f5565592b44808d7f0f25815010eb9d.tar.gz cpython-2153dc001f5565592b44808d7f0f25815010eb9d.tar.bz2 |
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/builtin/test_loader.py')
-rw-r--r-- | Lib/importlib/test/builtin/test_loader.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/importlib/test/builtin/test_loader.py b/Lib/importlib/test/builtin/test_loader.py index dff00ce..1a8539b 100644 --- a/Lib/importlib/test/builtin/test_loader.py +++ b/Lib/importlib/test/builtin/test_loader.py @@ -54,13 +54,15 @@ class LoaderTests(abc.LoaderTests): def test_unloadable(self): name = 'dssdsdfff' assert name not in sys.builtin_module_names - self.assertRaises(ImportError, self.load_module, name) + with self.assertRaises(ImportError): + self.load_module(name) def test_already_imported(self): # Using the name of a module already imported but not a built-in should # still fail. assert hasattr(importlib, '__file__') # Not a built-in. - self.assertRaises(ImportError, self.load_module, 'importlib') + with self.assertRaises(ImportError): + self.load_module('importlib') class InspectLoaderTests(unittest.TestCase): @@ -86,7 +88,8 @@ class InspectLoaderTests(unittest.TestCase): # Modules not built-in should raise ImportError. for meth_name in ('get_code', 'get_source', 'is_package'): method = getattr(machinery.BuiltinImporter, meth_name) - self.assertRaises(ImportError, method, builtin_util.BAD_NAME) + with self.assertRaises(ImportError): + method(builtin_util.BAD_NAME) |