mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
c5951fc996
commit
2153dc001f
9 changed files with 36 additions and 24 deletions
|
@ -51,8 +51,8 @@ class LoaderTests(abc.LoaderTests):
|
|||
|
||||
def test_unloadable(self):
|
||||
assert machinery.FrozenImporter.find_module('_not_real') is None
|
||||
self.assertRaises(ImportError, machinery.FrozenImporter.load_module,
|
||||
'_not_real')
|
||||
with self.assertRaises(ImportError):
|
||||
machinery.FrozenImporter.load_module('_not_real')
|
||||
|
||||
|
||||
class InspectLoaderTests(unittest.TestCase):
|
||||
|
@ -84,7 +84,8 @@ class InspectLoaderTests(unittest.TestCase):
|
|||
# Raise ImportError for modules that are not frozen.
|
||||
for meth_name in ('get_code', 'get_source', 'is_package'):
|
||||
method = getattr(machinery.FrozenImporter, meth_name)
|
||||
self.assertRaises(ImportError, method, 'importlib')
|
||||
with self.assertRaises(ImportError):
|
||||
method('importlib')
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue