def test_charmap_encode(): #Sanity AreEqual(codecs.charmap_encode("abc"), ('abc', 3)) AreEqual(codecs.charmap_encode("abc", "strict"), ('abc', 3)) AreEqual(codecs.charmap_encode("", "strict", {}), ('', 0)) charmap = dict([(ord(c), c.upper()) for c in "abcdefgh"]) AreEqual(codecs.charmap_encode("abc", "strict", charmap), ('ABC', 3)) if not is_silverlight: #Sanity Negative AssertError(UnicodeEncodeError, codecs.charmap_encode, "abc", "strict", {})
def test_charmap_encode(): #Sanity AreEqual(codecs.charmap_encode("abc"), ('abc', 3)) AreEqual(codecs.charmap_encode("abc", "strict"), ('abc', 3)) AreEqual(codecs.charmap_encode("", "strict", {}), ('', 0)) charmap = dict([ (ord(c), c.upper()) for c in "abcdefgh"]) AreEqual(codecs.charmap_encode(u"abc", "strict", charmap), ('ABC', 3)) if not is_silverlight: #Sanity Negative AssertError(UnicodeEncodeError, codecs.charmap_encode, "abc", "strict", {})
def test_charmap_build(): decodemap = ''.join([ chr(i).upper() if chr(i).islower() else chr(i).lower() for i in range(256) ]) encodemap = codecs.charmap_build(decodemap) AreEqual(codecs.charmap_decode('Hello World', 'strict', decodemap), ('hELLO wORLD', 11)) AreEqual(codecs.charmap_encode('Hello World', 'strict', encodemap), ('hELLO wORLD', 11))
def test_charmap_build(): decodemap = ''.join([unichr(i).upper() if chr(i).islower() else unichr(i).lower() for i in xrange(256)]) encodemap = codecs.charmap_build(decodemap) AreEqual(codecs.charmap_decode(u'Hello World', 'strict', decodemap), ('hELLO wORLD', 11)) AreEqual(codecs.charmap_encode(u'Hello World', 'strict', encodemap), ('hELLO wORLD', 11))