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:
Brett Cannon 2009-08-27 23:49:21 +00:00
parent c5951fc996
commit 2153dc001f
9 changed files with 36 additions and 24 deletions

View file

@ -97,8 +97,8 @@ class FinderTests(abc.FinderTests):
with context as mapping:
os.unlink(mapping['pkg.sub.__init__'])
pkg_dir = os.path.dirname(mapping['pkg.__init__'])
self.assertRaises(ImportWarning, self.import_, pkg_dir,
'pkg.sub')
with self.assertRaises(ImportWarning):
self.import_(pkg_dir, 'pkg.sub')
# [package over modules]
def test_package_over_module(self):
@ -117,8 +117,8 @@ class FinderTests(abc.FinderTests):
def test_empty_dir(self):
with warnings.catch_warnings():
warnings.simplefilter("error", ImportWarning)
self.assertRaises(ImportWarning, self.run_test, 'pkg',
{'pkg.__init__'}, unlink={'pkg.__init__'})
with self.assertRaises(ImportWarning):
self.run_test('pkg', {'pkg.__init__'}, unlink={'pkg.__init__'})
def test_main():