summaryrefslogtreecommitdiff
path: root/Lib/importlib/test/source/test_abc_loader.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-12 21:09:01 -0400
committerBrett Cannon <brett@python.org>2012-04-12 21:09:01 -0400
commitbbb6680ee5650ad1096eba0c86286342c3d08468 (patch)
tree2b17a1b8beb11db23edf34adbc5684fadc829139 /Lib/importlib/test/source/test_abc_loader.py
parent79ec55e980d7b205bbc78d44e0892d0ef37d3abb (diff)
downloadcpython-git-bbb6680ee5650ad1096eba0c86286342c3d08468.tar.gz
Have importlib take advantage of ImportError's new 'name' and 'path'
attributes.
Diffstat (limited to 'Lib/importlib/test/source/test_abc_loader.py')
-rw-r--r--Lib/importlib/test/source/test_abc_loader.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/importlib/test/source/test_abc_loader.py b/Lib/importlib/test/source/test_abc_loader.py
index 01acda4b9a..b1b1204197 100644
--- a/Lib/importlib/test/source/test_abc_loader.py
+++ b/Lib/importlib/test/source/test_abc_loader.py
@@ -471,8 +471,9 @@ class BadBytecodeFailureTests(unittest.TestCase):
{'path': os.path.join('path', 'to', 'mod'),
'magic': bad_magic}}
mock = PyPycLoaderMock({name: None}, bc)
- with util.uncache(name), self.assertRaises(ImportError):
+ with util.uncache(name), self.assertRaises(ImportError) as cm:
mock.load_module(name)
+ self.assertEqual(cm.exception.name, name)
def test_no_bytecode(self):
# Missing code object bytecode should lead to an EOFError.
@@ -516,8 +517,9 @@ class MissingPathsTests(unittest.TestCase):
# If all *_path methods return None, raise ImportError.
name = 'mod'
mock = PyPycLoaderMock({name: None})
- with util.uncache(name), self.assertRaises(ImportError):
+ with util.uncache(name), self.assertRaises(ImportError) as cm:
mock.load_module(name)
+ self.assertEqual(cm.exception.name, name)
def test_source_path_ImportError(self):
# An ImportError from source_path should trigger an ImportError.
@@ -533,7 +535,7 @@ class MissingPathsTests(unittest.TestCase):
mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')})
bad_meth = types.MethodType(raise_ImportError, mock)
mock.bytecode_path = bad_meth
- with util.uncache(name), self.assertRaises(ImportError):
+ with util.uncache(name), self.assertRaises(ImportError) as cm:
mock.load_module(name)
@@ -594,8 +596,9 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
def raise_IOError(path):
raise IOError
self.loader.get_data = raise_IOError
- with self.assertRaises(ImportError):
+ with self.assertRaises(ImportError) as cm:
self.loader.get_source(self.name)
+ self.assertEqual(cm.exception.name, self.name)
def test_is_package(self):
# Properly detect when loading a package.