]> granicus.if.org Git - python/commitdiff
Silence UnicodeWarning in crazy unittest test.
authorMichael Foord <fuzzyman@voidspace.org.uk>
Sun, 21 Feb 2010 14:48:59 +0000 (14:48 +0000)
committerMichael Foord <fuzzyman@voidspace.org.uk>
Sun, 21 Feb 2010 14:48:59 +0000 (14:48 +0000)
Lib/test/test_unittest.py

index d3bab2af86f732e700da5ae9a23d70ffbd1a3905..df760a76d61e9bb755fec92be1a6a9cf44ac622f 100644 (file)
@@ -16,6 +16,7 @@ import types
 from copy import deepcopy
 from cStringIO import StringIO
 import pickle
+import warnings
 
 
 ### Support code
@@ -2573,10 +2574,12 @@ class Test_TestCase(TestCase, TestEquality, TestHashing):
         with self.assertRaises(self.failureException):
             self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
 
-        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': u'\uFFFD'})
+        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': u'\uFFFD'})
 
     def testAssertEqual(self):
         equal_pairs = [