diff options
| author | Brett Cannon <brett@python.org> | 2012-04-13 01:09:01 (GMT) |
|---|---|---|
| committer | Brett Cannon <brett@python.org> | 2012-04-13 01:09:01 (GMT) |
| commit | bbb6680ee5650ad1096eba0c86286342c3d08468 (patch) | |
| tree | 2b17a1b8beb11db23edf34adbc5684fadc829139 /Lib/importlib/test/builtin/test_loader.py | |
| parent | 79ec55e980d7b205bbc78d44e0892d0ef37d3abb (diff) | |
| download | cpython-bbb6680ee5650ad1096eba0c86286342c3d08468.zip cpython-bbb6680ee5650ad1096eba0c86286342c3d08468.tar.gz cpython-bbb6680ee5650ad1096eba0c86286342c3d08468.tar.bz2 | |
Have importlib take advantage of ImportError's new 'name' and 'path'
attributes.
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 1a8539b..ec126c9 100644 --- a/Lib/importlib/test/builtin/test_loader.py +++ b/Lib/importlib/test/builtin/test_loader.py @@ -54,15 +54,17 @@ class LoaderTests(abc.LoaderTests): def test_unloadable(self): name = 'dssdsdfff' assert name not in sys.builtin_module_names - with self.assertRaises(ImportError): + with self.assertRaises(ImportError) as cm: self.load_module(name) + self.assertEqual(cm.exception.name, 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. - with self.assertRaises(ImportError): + with self.assertRaises(ImportError) as cm: self.load_module('importlib') + self.assertEqual(cm.exception.name, 'importlib') class InspectLoaderTests(unittest.TestCase): @@ -88,8 +90,9 @@ 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) - with self.assertRaises(ImportError): + with self.assertRaises(ImportError) as cm: method(builtin_util.BAD_NAME) + self.assertRaises(builtin_util.BAD_NAME) |
