summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importhooks.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-21 11:58:11 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-21 11:58:11 (GMT)
commitb88fbf4fef9e03cfe9121dc03d935c9a90ff19b1 (patch)
tree3e8652622e626fb151cc60d4faf337217de8cbc2 /Lib/test/test_importhooks.py
parentaa89f8d04c209bdc2816f4715b9b6a28e81720cc (diff)
downloadcpython-b88fbf4fef9e03cfe9121dc03d935c9a90ff19b1.zip
cpython-b88fbf4fef9e03cfe9121dc03d935c9a90ff19b1.tar.gz
cpython-b88fbf4fef9e03cfe9121dc03d935c9a90ff19b1.tar.bz2
Use assertRaises and add a specific warning filter.
Diffstat (limited to 'Lib/test/test_importhooks.py')
-rw-r--r--Lib/test/test_importhooks.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index b323f58..cfab1f2 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -227,15 +227,9 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
def testBlocker(self):
mname = "exceptions" # an arbitrary harmless builtin module
- if mname in sys.modules:
- del sys.modules[mname]
+ test_support.unload(mname)
sys.meta_path.append(ImportBlocker(mname))
- try:
- __import__(mname)
- except ImportError:
- pass
- else:
- self.fail("'%s' was not supposed to be importable" % mname)
+ self.assertRaises(ImportError, __import__, mname)
def testImpWrapper(self):
i = ImpWrapper()
@@ -247,7 +241,8 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
for n in sys.modules.keys():
if n.startswith(parent):
del sys.modules[n]
- with test_support.check_warnings():
+ with test_support.check_warnings(("The compiler package is deprecated "
+ "and removed", DeprecationWarning)):
for mname in mnames:
m = __import__(mname, globals(), locals(), ["__dummy__"])
m.__loader__ # to make sure we actually handled the import