cpython/Lib/test/test_charmapcodec.py
Walter Dörwald 21d3a32b99 Combine the functionality of test_support.run_unittest()
and test_support.run_classtests() into run_unittest()
and use it wherever possible.

Also don't use "from test.test_support import ...", but
"from test import test_support" in a few spots.

From SF patch #662807.
2003-05-01 17:45:56 +00:00

46 lines
1.6 KiB
Python

""" Python character mapping codec test
This uses the test codec in testcodec.py and thus also tests the
encodings package lookup scheme.
Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright 2000 Guido van Rossum.
"""#"
import test.test_support, unittest
# test codec's full path name (see test/testcodec.py)
codecname = 'test.testcodec'
class CharmapCodecTest(unittest.TestCase):
def test_constructorx(self):
self.assertEquals(unicode('abc', codecname), u'abc')
self.assertEquals(unicode('xdef', codecname), u'abcdef')
self.assertEquals(unicode('defx', codecname), u'defabc')
self.assertEquals(unicode('dxf', codecname), u'dabcf')
self.assertEquals(unicode('dxfx', codecname), u'dabcfabc')
def test_encodex(self):
self.assertEquals(u'abc'.encode(codecname), 'abc')
self.assertEquals(u'xdef'.encode(codecname), 'abcdef')
self.assertEquals(u'defx'.encode(codecname), 'defabc')
self.assertEquals(u'dxf'.encode(codecname), 'dabcf')
self.assertEquals(u'dxfx'.encode(codecname), 'dabcfabc')
def test_constructory(self):
self.assertEquals(unicode('ydef', codecname), u'def')
self.assertEquals(unicode('defy', codecname), u'def')
self.assertEquals(unicode('dyf', codecname), u'df')
self.assertEquals(unicode('dyfy', codecname), u'df')
def test_maptoundefined(self):
self.assertRaises(UnicodeError, unicode, 'abc\001', codecname)
def test_main():
test.test_support.run_unittest(CharmapCodecTest)
if __name__ == "__main__":
test_main()