summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_warnings.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-04-01 20:25:48 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-04-01 20:25:48 (GMT)
commitce3d22144781845784d17fa3b4b3e034d2d448f0 (patch)
treee7a891e797b584d5fac28f3e52540010f534bdf8 /Lib/test/test_warnings.py
parent2da4d628a5100627876a55e6a911d59570cd8c69 (diff)
downloadcpython-ce3d22144781845784d17fa3b4b3e034d2d448f0.zip
cpython-ce3d22144781845784d17fa3b4b3e034d2d448f0.tar.gz
cpython-ce3d22144781845784d17fa3b4b3e034d2d448f0.tar.bz2
test_warnings ironically had a single test that was not protecting the warnings
filter and was resetting it.
Diffstat (limited to 'Lib/test/test_warnings.py')
-rw-r--r--Lib/test/test_warnings.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index bc177ad..bb2fb5f 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -460,14 +460,14 @@ class _WarningsTests(BaseTest):
self.failUnless(text in result)
def test_showwarning_not_callable(self):
- self.module.filterwarnings("always", category=UserWarning)
- old_showwarning = self.module.showwarning
- self.module.showwarning = 23
- try:
- self.assertRaises(TypeError, self.module.warn, "Warning!")
- finally:
- self.module.showwarning = old_showwarning
- self.module.resetwarnings()
+ with original_warnings.catch_warnings(module=self.module):
+ self.module.filterwarnings("always", category=UserWarning)
+ old_showwarning = self.module.showwarning
+ self.module.showwarning = 23
+ try:
+ self.assertRaises(TypeError, self.module.warn, "Warning!")
+ finally:
+ self.module.showwarning = old_showwarning
def test_show_warning_output(self):
# With showarning() missing, make sure that output is okay.