diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-28 00:25:02 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-28 00:25:02 (GMT) |
commit | fd1b0930ce6a84096d30c03a70cd9e0ee4a3178f (patch) | |
tree | 349bba5ec56f76a0fc2b5d04fbcb9d7945241413 /Lib/unittest | |
parent | c049d870b58107945d8e9784df1fdfbd4e9fa6be (diff) | |
download | cpython-fd1b0930ce6a84096d30c03a70cd9e0ee4a3178f.zip cpython-fd1b0930ce6a84096d30c03a70cd9e0ee4a3178f.tar.gz cpython-fd1b0930ce6a84096d30c03a70cd9e0ee4a3178f.tar.bz2 |
Merged revisions 79297,79310,79382,79425-79427,79450 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79297 | florent.xicluna | 2010-03-22 18:18:18 +0100 (lun, 22 mar 2010) | 2 lines
#7668: Fix test_httpservers failure when sys.executable contains non-ASCII bytes.
........
r79310 | florent.xicluna | 2010-03-22 23:52:11 +0100 (lun, 22 mar 2010) | 2 lines
Issue #8205: Remove the "Modules" directory from sys.path when Python is running from the build directory (POSIX only).
........
r79382 | florent.xicluna | 2010-03-24 20:33:25 +0100 (mer, 24 mar 2010) | 2 lines
Skip tests which depend on multiprocessing.sharedctypes, if _ctypes is not available.
........
r79425 | florent.xicluna | 2010-03-25 21:32:07 +0100 (jeu, 25 mar 2010) | 2 lines
Syntax cleanup `== None` -> `is None`
........
r79426 | florent.xicluna | 2010-03-25 21:33:49 +0100 (jeu, 25 mar 2010) | 2 lines
#8207: Fix test_pep277 on OS X
........
r79427 | florent.xicluna | 2010-03-25 21:39:10 +0100 (jeu, 25 mar 2010) | 2 lines
Fix test_unittest and test_warnings when running "python -Werror -m test.regrtest"
........
r79450 | florent.xicluna | 2010-03-26 20:32:44 +0100 (ven, 26 mar 2010) | 2 lines
Ensure that the failed or unexpected tests are sorted before printing.
........
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/test/test_assertions.py | 10 | ||||
-rw-r--r-- | Lib/unittest/test/test_case.py | 20 | ||||
-rw-r--r-- | Lib/unittest/test/test_result.py | 5 |
3 files changed, 13 insertions, 22 deletions
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py index 68a723a..fe65849 100644 --- a/Lib/unittest/test/test_assertions.py +++ b/Lib/unittest/test/test_assertions.py @@ -1,7 +1,5 @@ import unittest -import warnings - class Test_Assertions(unittest.TestCase): def test_AlmostEqual(self): @@ -108,11 +106,9 @@ class TestLongMessage(unittest.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, '\uFFFD') + one = ''.join(chr(i) for i in range(255)) + # this used to cause a UnicodeDecodeError constructing msg + self.testableTrue._formatMessage(one, '\uFFFD') def assertMessages(self, methodName, args, errors): def getMethod(i): diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py index c9f346f..08c4a7b 100644 --- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -1,6 +1,5 @@ import re import sys -import warnings from copy import deepcopy from test import support @@ -496,12 +495,10 @@ class Test_TestCase(unittest.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 - one = ''.join(chr(i) for i in range(255)) - # this used to cause a UnicodeDecodeError constructing the failure msg - with self.assertRaises(self.failureException): - self.assertDictContainsSubset({'foo': one}, {'foo': '\uFFFD'}) + one = ''.join(chr(i) for i in range(255)) + # this used to cause a UnicodeDecodeError constructing the failure msg + with self.assertRaises(self.failureException): + self.assertDictContainsSubset({'foo': one}, {'foo': '\uFFFD'}) def testAssertEqual(self): equal_pairs = [ @@ -615,9 +612,9 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing): # hashable types, but not orderable self.assertRaises(self.failureException, self.assertItemsEqual, [], [divmod, 'x', 1, 5j, 2j, frozenset()]) - # comparing dicts raises a py3k warning + # comparing dicts self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}]) - # comparing heterogenous non-hashable sequences raises a py3k warning + # comparing heterogenous non-hashable sequences self.assertItemsEqual([1, 'x', divmod, []], [divmod, [], 'x', 1]) self.assertRaises(self.failureException, self.assertItemsEqual, [], [divmod, [], 'x', 1, 5j, 2j, set()]) @@ -852,10 +849,9 @@ test case (self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3])) ) for meth, args in old: - with warnings.catch_warnings(record=True) as w: + with support.check_warnings(('', DeprecationWarning)) as w: meth(*args) - self.assertEqual(len(w), 1) - self.assertIs(w[0].category, DeprecationWarning) + self.assertEqual(len(w.warnings), 1) def testDeepcopy(self): # Issue: 5660 diff --git a/Lib/unittest/test/test_result.py b/Lib/unittest/test/test_result.py index 9002466..967b662 100644 --- a/Lib/unittest/test/test_result.py +++ b/Lib/unittest/test/test_result.py @@ -308,12 +308,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 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): |