]> granicus.if.org Git - python/commitdiff
Silence DeprecationWarnings in test_unicode.
authorEzio Melotti <ezio.melotti@gmail.com>
Wed, 20 Feb 2013 21:56:01 +0000 (23:56 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Wed, 20 Feb 2013 21:56:01 +0000 (23:56 +0200)
Lib/test/test_unicode.py

index f7d868659542178e47a750dc80d8ebf39141d087..d4e2222fa92dc43a337f5df6bf23cc87e779e51c 100644 (file)
@@ -2172,15 +2172,17 @@ class UnicodeTest(string_tests.CommonTest,
             # generate a fresh string (refcount=1)
             text = 'a' * length + 'b'
 
-            # fill wstr internal field
-            abc = text.encode('unicode_internal')
-            self.assertEqual(abc.decode('unicode_internal'), text)
-
-            # resize text: wstr field must be cleared and then recomputed
-            text += 'c'
-            abcdef = text.encode('unicode_internal')
-            self.assertNotEqual(abc, abcdef)
-            self.assertEqual(abcdef.decode('unicode_internal'), text)
+            with support.check_warnings(('unicode_internal codec has been '
+                                         'deprecated', DeprecationWarning)):
+                # fill wstr internal field
+                abc = text.encode('unicode_internal')
+                self.assertEqual(abc.decode('unicode_internal'), text)
+
+                # resize text: wstr field must be cleared and then recomputed
+                text += 'c'
+                abcdef = text.encode('unicode_internal')
+                self.assertNotEqual(abc, abcdef)
+                self.assertEqual(abcdef.decode('unicode_internal'), text)
 
 
 class StringModuleTest(unittest.TestCase):