summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-25 20:39:10 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-25 20:39:10 (GMT)
commitfd37dd46e87b6638dbf585c83a14f7c6047741d1 (patch)
tree19a54b28c5e38212d0608a55cb49c62b81e801a4 /Lib
parent8aa5a581d3b85d44bbad33e9ad1148430f9aba45 (diff)
downloadcpython-fd37dd46e87b6638dbf585c83a14f7c6047741d1.zip
cpython-fd37dd46e87b6638dbf585c83a14f7c6047741d1.tar.gz
cpython-fd37dd46e87b6638dbf585c83a14f7c6047741d1.tar.bz2
Fix test_unittest and test_warnings when running "python -Werror -m test.regrtest"
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_unittest.py17
-rw-r--r--Lib/test/test_warnings.py5
2 files changed, 11 insertions, 11 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index 5d51ffc..034a5f0 100644
--- a/Lib/test/test_unittest.py
+++ b/Lib/test/test_unittest.py
@@ -16,7 +16,6 @@ import types
from copy import deepcopy
from cStringIO import StringIO
import pickle
-import warnings
### Support code
@@ -2136,12 +2135,11 @@ OldResult = type('OldResult', (object,), classDict)
class Test_OldTestResult(unittest.TestCase):
def assertOldResultWarning(self, test, failures):
- with warnings.catch_warnings(record=True) as log:
+ with test_support.check_warnings(("TestResult has no add.+ method,",
+ RuntimeWarning)):
result = OldResult()
test.run(result)
self.assertEqual(len(result.failures), failures)
- warning, = log
- self.assertIs(warning.category, RuntimeWarning)
def testOldTestResult(self):
class Test(unittest.TestCase):
@@ -2702,8 +2700,7 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
with self.assertRaises(self.failureException):
self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
- with warnings.catch_warnings(record=True):
- # silence the UnicodeWarning
+ with test_support.check_warnings(("", UnicodeWarning)):
one = ''.join(chr(i) for i in range(255))
# this used to cause a UnicodeDecodeError constructing the failure msg
with self.assertRaises(self.failureException):
@@ -3348,11 +3345,9 @@ class TestLongMessage(TestCase):
self.testableTrue._formatMessage(object(), 'foo')
def test_formatMessage_unicode_error(self):
- with warnings.catch_warnings(record=True):
- # This causes a UnicodeWarning due to its craziness
- one = ''.join(chr(i) for i in range(255))
- # this used to cause a UnicodeDecodeError constructing msg
- self.testableTrue._formatMessage(one, u'\uFFFD')
+ one = ''.join(chr(i) for i in range(255))
+ # this used to cause a UnicodeDecodeError constructing msg
+ self.testableTrue._formatMessage(one, u'\uFFFD')
def assertMessages(self, methodName, args, errors):
def getMethod(i):
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 79922b2..a0a65b4 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -27,11 +27,15 @@ def warnings_state(module):
except NameError:
pass
original_warnings = warning_tests.warnings
+ original_filters = module.filters
try:
+ module.filters = original_filters[:]
+ module.simplefilter("once")
warning_tests.warnings = module
yield
finally:
warning_tests.warnings = original_warnings
+ module.filters = original_filters
class BaseTest(unittest.TestCase):
@@ -194,6 +198,7 @@ class WarnTests(unittest.TestCase):
def test_message(self):
with original_warnings.catch_warnings(record=True,
module=self.module) as w:
+ self.module.simplefilter("once")
for i in range(4):
text = 'multi %d' %i # Different text on each call.
self.module.warn(text)