~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to lib-python/2.4.1/test/test_codecencodings_kr.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# test_codecencodings_kr.py
 
4
#   Codec encoding tests for ROK encodings.
 
5
#
 
6
# $CJKCodecs: test_codecencodings_kr.py,v 1.2 2004/06/19 06:09:55 perky Exp $
 
7
 
 
8
from test import test_support
 
9
from test import test_multibytecodec_support
 
10
import unittest
 
11
 
 
12
class Test_CP949(test_multibytecodec_support.TestBase, unittest.TestCase):
 
13
    encoding = 'cp949'
 
14
    tstring = test_multibytecodec_support.load_teststring('cp949')
 
15
    codectests = (
 
16
        # invalid bytes
 
17
        ("abc\x80\x80\xc1\xc4", "strict",  None),
 
18
        ("abc\xc8", "strict",  None),
 
19
        ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"),
 
20
        ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"),
 
21
        ("abc\x80\x80\xc1\xc4", "ignore",  u"abc\uc894"),
 
22
    )
 
23
 
 
24
class Test_EUCKR(test_multibytecodec_support.TestBase, unittest.TestCase):
 
25
    encoding = 'euc_kr'
 
26
    tstring = test_multibytecodec_support.load_teststring('euc_kr')
 
27
    codectests = (
 
28
        # invalid bytes
 
29
        ("abc\x80\x80\xc1\xc4", "strict",  None),
 
30
        ("abc\xc8", "strict",  None),
 
31
        ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"),
 
32
        ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"),
 
33
        ("abc\x80\x80\xc1\xc4", "ignore",  u"abc\uc894"),
 
34
    )
 
35
 
 
36
class Test_JOHAB(test_multibytecodec_support.TestBase, unittest.TestCase):
 
37
    encoding = 'johab'
 
38
    tstring = test_multibytecodec_support.load_teststring('johab')
 
39
    codectests = (
 
40
        # invalid bytes
 
41
        ("abc\x80\x80\xc1\xc4", "strict",  None),
 
42
        ("abc\xc8", "strict",  None),
 
43
        ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\ucd27"),
 
44
        ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\ucd27\ufffd"),
 
45
        ("abc\x80\x80\xc1\xc4", "ignore",  u"abc\ucd27"),
 
46
    )
 
47
 
 
48
def test_main():
 
49
    suite = unittest.TestSuite()
 
50
    suite.addTest(unittest.makeSuite(Test_CP949))
 
51
    suite.addTest(unittest.makeSuite(Test_EUCKR))
 
52
    suite.addTest(unittest.makeSuite(Test_JOHAB))
 
53
    test_support.run_suite(suite)
 
54
 
 
55
if __name__ == "__main__":
 
56
    test_main()