summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tempfile.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-03-20 22:19:55 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-03-20 22:19:55 (GMT)
commite1adeceb0c2daafe36011300594650c906747674 (patch)
tree04a5b13e19394542f4c1eec6ff0dc21a606174c9 /Lib/test/test_tempfile.py
parent241bd9827b4b29813088249fbd22a8e969e5b393 (diff)
downloadcpython-e1adeceb0c2daafe36011300594650c906747674.zip
cpython-e1adeceb0c2daafe36011300594650c906747674.tar.gz
cpython-e1adeceb0c2daafe36011300594650c906747674.tar.bz2
Clean up warnings filter use in test_tempfile.
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r--Lib/test/test_tempfile.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 0dd8fc4..823c3d4 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -8,9 +8,6 @@ import warnings
import unittest
from test import support
-warnings.filterwarnings("ignore",
- category=RuntimeWarning,
- message="mktemp", module=__name__)
if hasattr(os, 'stat'):
import stat
@@ -39,6 +36,16 @@ class TC(unittest.TestCase):
str_check = re.compile(r"[a-zA-Z0-9_-]{6}$")
+ def setUp(self):
+ self._warnings_manager = support.check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("ignore", category=RuntimeWarning,
+ message="mktemp", module=__name__)
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
+
def failOnException(self, what, ei=None):
if ei is None:
ei = sys.exc_info()
@@ -98,6 +105,7 @@ class test__RandomNameSequence(TC):
def setUp(self):
self.r = tempfile._RandomNameSequence()
+ super().setUp()
def test_get_six_char_str(self):
# _RandomNameSequence returns a six-character string
@@ -499,11 +507,13 @@ class test_mktemp(TC):
# We must also suppress the RuntimeWarning it generates.
def setUp(self):
self.dir = tempfile.mkdtemp()
+ super().setUp()
def tearDown(self):
if self.dir:
os.rmdir(self.dir)
self.dir = None
+ super().tearDown()
class mktemped:
_unlink = os.unlink