def test_unicode_internal_decode(): ''' ''' # takes one or two parameters, not zero or three AssertError(TypeError, codecs.unicode_internal_decode) AssertError(TypeError, codecs.unicode_internal_decode, 'abc', 'def', 'qrt') AreEqual(codecs.unicode_internal_decode('ab'), (u'\u6261', 2))
def test_unicode_internal_decode(self): import sys, _codecs, array if sys.maxunicode == 65535: # UCS2 build if sys.byteorder == "big": bytes = b"\x00a" else: bytes = b"a\x00" else: # UCS4 build if sys.byteorder == "big": bytes = b"\x00\x00\x00a" bytes2 = b"\x00\x01\x00\x98" else: bytes = b"a\x00\x00\x00" bytes2 = b"\x98\x00\x01\x00" assert bytes2.decode("unicode_internal") == "\U00010098" assert bytes.decode("unicode_internal") == "a" assert _codecs.unicode_internal_decode(array.array('b', bytes))[0] == u"a" assert _codecs.unicode_internal_decode(memoryview(bytes))[0] == u"a"
def test_unicode_internal_decode(self): import sys, _codecs, array if sys.maxunicode == 65535: # UCS2 build if sys.byteorder == "big": bytes = "\x00a" else: bytes = "a\x00" else: # UCS4 build if sys.byteorder == "big": bytes = "\x00\x00\x00a" bytes2 = "\x00\x01\x00\x98" else: bytes = "a\x00\x00\x00" bytes2 = "\x98\x00\x01\x00" assert bytes2.decode("unicode_internal") == u"\U00010098" assert bytes.decode("unicode_internal") == u"a" assert _codecs.unicode_internal_decode(array.array('c', bytes))[0] == u"a" if '__pypy__' in sys.modules: assert _codecs.unicode_internal_decode(memoryview(bytes))[0] == u"a"
def test_unicode_internal_decode(self): import sys, _codecs, array if sys.maxunicode == 65535: # UCS2 build if sys.byteorder == "big": bytes = b"\x00a" else: bytes = b"a\x00" else: # UCS4 build if sys.byteorder == "big": bytes = b"\x00\x00\x00a" bytes2 = b"\x00\x01\x00\x98" else: bytes = b"a\x00\x00\x00" bytes2 = b"\x98\x00\x01\x00" assert bytes2.decode("unicode_internal") == "\U00010098" assert bytes.decode("unicode_internal") == "a" assert _codecs.unicode_internal_decode(array.array('b', bytes))[0] == u"a" assert _codecs.unicode_internal_decode(memoryview(bytes))[0] == u"a" # This codec accepts bytes and unicode on both sides _codecs.unicode_internal_decode(u'\0\0\0\0') _codecs.unicode_internal_decode(b'\0\0\0\0') _codecs.unicode_internal_encode(u'\0\0\0\0') _codecs.unicode_internal_encode(b'\0\0\0\0')
def test_decode_bytearray(self): import _codecs b = bytearray() assert _codecs.ascii_decode(b) == (u'', 0) assert _codecs.latin_1_decode(b) == (u'', 0) assert _codecs.utf_7_decode(b) == (u'', 0) assert _codecs.utf_8_decode(b) == (u'', 0) assert _codecs.utf_16_be_decode(b) == (u'', 0) assert _codecs.utf_16_decode(b) == (u'', 0) assert _codecs.utf_16_le_decode(b) == (u'', 0) assert _codecs.utf_16_ex_decode(b) == (u'', 0, 0) assert _codecs.utf_32_decode(b) == (u'', 0) assert _codecs.utf_32_be_decode(b) == (u'', 0) assert _codecs.utf_32_le_decode(b) == (u'', 0) assert _codecs.utf_32_ex_decode(b) == (u'', 0, 0) assert _codecs.charmap_decode(b) == (u'', 0) assert _codecs.unicode_escape_decode(b) == (u'', 0) assert _codecs.raw_unicode_escape_decode(b) == (u'', 0) assert _codecs.unicode_internal_decode(b) == (u'', 0)
def test_unicode_internal_decode(self): import sys, _codecs, array if sys.maxunicode == 65535: # UCS2 build if sys.byteorder == "big": bytes = "\x00a" else: bytes = "a\x00" else: # UCS4 build if sys.byteorder == "big": bytes = "\x00\x00\x00a" bytes2 = "\x00\x01\x00\x98" else: bytes = "a\x00\x00\x00" bytes2 = "\x98\x00\x01\x00" assert bytes2.decode("unicode_internal") == u"\U00010098" assert bytes.decode("unicode_internal") == u"a" assert _codecs.unicode_internal_decode(array.array('c', bytes))[0] == u"a" exc = raises(TypeError, _codecs.unicode_internal_decode, memoryview(bytes)) assert str(exc.value) == "expected a readable buffer object"