Esempio n. 1
0
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))
Esempio n. 2
0
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))