home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / test_charmapcodec.py < prev    next >
Text File  |  2003-12-30  |  2KB  |  46 lines

  1. """ Python character mapping codec test
  2.  
  3. This uses the test codec in testcodec.py and thus also tests the
  4. encodings package lookup scheme.
  5.  
  6. Written by Marc-Andre Lemburg (mal@lemburg.com).
  7.  
  8. (c) Copyright 2000 Guido van Rossum.
  9.  
  10. """#"
  11.  
  12. import test.test_support, unittest
  13.  
  14. # test codec's full path name (see test/testcodec.py)
  15. codecname = 'test.testcodec'
  16.  
  17. class CharmapCodecTest(unittest.TestCase):
  18.     def test_constructorx(self):
  19.         self.assertEquals(unicode('abc', codecname), u'abc')
  20.         self.assertEquals(unicode('xdef', codecname), u'abcdef')
  21.         self.assertEquals(unicode('defx', codecname), u'defabc')
  22.         self.assertEquals(unicode('dxf', codecname), u'dabcf')
  23.         self.assertEquals(unicode('dxfx', codecname), u'dabcfabc')
  24.  
  25.     def test_encodex(self):
  26.         self.assertEquals(u'abc'.encode(codecname), 'abc')
  27.         self.assertEquals(u'xdef'.encode(codecname), 'abcdef')
  28.         self.assertEquals(u'defx'.encode(codecname), 'defabc')
  29.         self.assertEquals(u'dxf'.encode(codecname), 'dabcf')
  30.         self.assertEquals(u'dxfx'.encode(codecname), 'dabcfabc')
  31.  
  32.     def test_constructory(self):
  33.         self.assertEquals(unicode('ydef', codecname), u'def')
  34.         self.assertEquals(unicode('defy', codecname), u'def')
  35.         self.assertEquals(unicode('dyf', codecname), u'df')
  36.         self.assertEquals(unicode('dyfy', codecname), u'df')
  37.  
  38.     def test_maptoundefined(self):
  39.         self.assertRaises(UnicodeError, unicode, 'abc\001', codecname)
  40.  
  41. def test_main():
  42.     test.test_support.run_unittest(CharmapCodecTest)
  43.  
  44. if __name__ == "__main__":
  45.     test_main()
  46.