[Python-checkins] r79155 - python/branches/py3k/Lib/test/test_tempfile.py
brett.cannon
python-checkins at python.org
Sat Mar 20 23:19:55 CET 2010
Author: brett.cannon
Date: Sat Mar 20 23:19:55 2010
New Revision: 79155
Log:
Clean up warnings filter use in test_tempfile.
Modified:
python/branches/py3k/Lib/test/test_tempfile.py
Modified: python/branches/py3k/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_tempfile.py (original)
+++ python/branches/py3k/Lib/test/test_tempfile.py Sat Mar 20 23:19:55 2010
@@ -8,9 +8,6 @@
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 @@
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 @@
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 @@
# 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
More information about the Python-checkins
mailing list