0001 """ Python character mapping codec test 0002 0003 This uses the test codec in testcodec.py and thus also tests the 0004 encodings package lookup scheme. 0005 0006 Written by Marc-Andre Lemburg (mal@lemburg.com). 0007 0008 (c) Copyright 2000 Guido van Rossum. 0009 0010 """#" 0011 0012 import test.test_support, unittest 0013 0014 # test codec's full path name (see test/testcodec.py) 0015 codecname = 'test.testcodec' 0016 0017 class CharmapCodecTest(unittest.TestCase): 0018 def test_constructorx(self): 0019 self.assertEquals(unicode('abc', codecname), u'abc') 0020 self.assertEquals(unicode('xdef', codecname), u'abcdef') 0021 self.assertEquals(unicode('defx', codecname), u'defabc') 0022 self.assertEquals(unicode('dxf', codecname), u'dabcf') 0023 self.assertEquals(unicode('dxfx', codecname), u'dabcfabc') 0024 0025 def test_encodex(self): 0026 self.assertEquals(u'abc'.encode(codecname), 'abc') 0027 self.assertEquals(u'xdef'.encode(codecname), 'abcdef') 0028 self.assertEquals(u'defx'.encode(codecname), 'defabc') 0029 self.assertEquals(u'dxf'.encode(codecname), 'dabcf') 0030 self.assertEquals(u'dxfx'.encode(codecname), 'dabcfabc') 0031 0032 def test_constructory(self): 0033 self.assertEquals(unicode('ydef', codecname), u'def') 0034 self.assertEquals(unicode('defy', codecname), u'def') 0035 self.assertEquals(unicode('dyf', codecname), u'df') 0036 self.assertEquals(unicode('dyfy', codecname), u'df') 0037 0038 def test_maptoundefined(self): 0039 self.assertRaises(UnicodeError, unicode, 'abc\001', codecname) 0040 0041 def test_main(): 0042 test.test_support.run_unittest(CharmapCodecTest) 0043 0044 if __name__ == "__main__": 0045 test_main() 0046
Generated by PyXR 0.9.4