diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-11-16 07:39:10 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-11-16 07:39:10 (GMT) |
commit | 11060a4a48811f7f13d8f71b5ece2acda112b6de (patch) | |
tree | 7804963ffa2564c0f2f20e208d0b64e8bd22ea7f /Lib | |
parent | 27c2a861ee83b9e46f560eb02d246e1074fda4f6 (diff) | |
download | cpython-11060a4a48811f7f13d8f71b5ece2acda112b6de.zip cpython-11060a4a48811f7f13d8f71b5ece2acda112b6de.tar.gz cpython-11060a4a48811f7f13d8f71b5ece2acda112b6de.tar.bz2 |
#13406: silence deprecation warnings in test_codecs.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_codecs.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index cc5d4bb..42c8fcf 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1025,17 +1025,22 @@ class UnicodeInternalTest(unittest.TestCase): for internal, uni in ok: if sys.byteorder == "little": internal = bytes(reversed(internal)) - self.assertEqual(uni, internal.decode("unicode_internal")) + with support.check_warnings(): + self.assertEqual(uni, internal.decode("unicode_internal")) for internal in not_ok: if sys.byteorder == "little": internal = bytes(reversed(internal)) - self.assertRaises(UnicodeDecodeError, internal.decode, - "unicode_internal") + with support.check_warnings(('unicode_internal codecs has been ' + 'deprecated', DeprecationWarning)): + self.assertRaises(UnicodeDecodeError, internal.decode, + "unicode_internal") @unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t') def test_decode_error_attributes(self): try: - b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal") + with support.check_warnings(('unicode_internal codecs has been ' + 'deprecated', DeprecationWarning)): + b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal") except UnicodeDecodeError as ex: self.assertEqual("unicode_internal", ex.encoding) self.assertEqual(b"\x00\x00\x00\x00\x00\x11\x11\x00", ex.object) @@ -1048,10 +1053,12 @@ class UnicodeInternalTest(unittest.TestCase): def test_decode_callback(self): codecs.register_error("UnicodeInternalTest", codecs.ignore_errors) decoder = codecs.getdecoder("unicode_internal") - ab = "ab".encode("unicode_internal").decode() - ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]), - "ascii"), - "UnicodeInternalTest") + with support.check_warnings(('unicode_internal codecs has been ' + 'deprecated', DeprecationWarning)): + ab = "ab".encode("unicode_internal").decode() + ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]), + "ascii"), + "UnicodeInternalTest") self.assertEqual(("ab", 12), ignored) def test_encode_length(self): |