Fix test_codecs for Windows: check size of wchar_t, not sys.maxunicode

This commit is contained in:
Victor Stinner 2011-09-29 19:53:55 +02:00
parent 734e159b12
commit 182d90d9ee
1 changed files with 43 additions and 40 deletions

View File

@ -3,6 +3,9 @@ import unittest
import codecs
import locale
import sys, _testcapi, io
import ctypes
SIZEOF_WCHAR_T = ctypes.sizeof(ctypes.c_wchar)
class Queue(object):
"""
@ -888,10 +891,10 @@ class PunycodeTest(unittest.TestCase):
self.assertEqual(uni, puny.decode("punycode"))
class UnicodeInternalTest(unittest.TestCase):
@unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t')
def test_bug1251300(self):
# Decoding with unicode_internal used to not correctly handle "code
# points" above 0x10ffff on UCS-4 builds.
if sys.maxunicode > 0xffff:
ok = [
(b"\x00\x10\xff\xff", "\U0010ffff"),
(b"\x00\x00\x01\x01", "\U00000101"),
@ -914,8 +917,8 @@ class UnicodeInternalTest(unittest.TestCase):
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):
if sys.maxunicode > 0xffff:
try:
b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal")
except UnicodeDecodeError as ex:
@ -926,8 +929,8 @@ class UnicodeInternalTest(unittest.TestCase):
else:
self.fail()
@unittest.skipUnless(SIZEOF_WCHAR_T == 4, 'specific to 32-bit wchar_t')
def test_decode_callback(self):
if sys.maxunicode > 0xffff:
codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
decoder = codecs.getdecoder("unicode_internal")
ab = "ab".encode("unicode_internal").decode()