~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Lib/test/test_codecmaps_jp.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# test_codecmaps_jp.py
 
4
#   Codec mapping tests for Japanese encodings
 
5
#
 
6
 
 
7
from test import support
 
8
from test import test_multibytecodec_support
 
9
import unittest
 
10
 
 
11
class TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
 
12
                   unittest.TestCase):
 
13
    encoding = 'cp932'
 
14
    mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \
 
15
                 'WINDOWS/CP932.TXT'
 
16
    supmaps = [
 
17
        (b'\x80', '\u0080'),
 
18
        (b'\xa0', '\uf8f0'),
 
19
        (b'\xfd', '\uf8f1'),
 
20
        (b'\xfe', '\uf8f2'),
 
21
        (b'\xff', '\uf8f3'),
 
22
    ]
 
23
    for i in range(0xa1, 0xe0):
 
24
        supmaps.append((bytes([i]), chr(i+0xfec0)))
 
25
 
 
26
 
 
27
class TestEUCJPCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
 
28
                         unittest.TestCase):
 
29
    encoding = 'euc_jp'
 
30
    mapfilename = 'EUC-JP.TXT'
 
31
    mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT'
 
32
 
 
33
 
 
34
class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
 
35
                        unittest.TestCase):
 
36
    encoding = 'shift_jis'
 
37
    mapfilename = 'SHIFTJIS.TXT'
 
38
    mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \
 
39
                 '/EASTASIA/JIS/SHIFTJIS.TXT'
 
40
    pass_enctest = [
 
41
        (b'\x81_', '\\'),
 
42
    ]
 
43
    pass_dectest = [
 
44
        (b'\\', '\xa5'),
 
45
        (b'~', '\u203e'),
 
46
        (b'\x81_', '\\'),
 
47
    ]
 
48
 
 
49
class TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
 
50
                         unittest.TestCase):
 
51
    encoding = 'euc_jisx0213'
 
52
    mapfilename = 'EUC-JISX0213.TXT'
 
53
    mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT'
 
54
 
 
55
 
 
56
class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
 
57
                       unittest.TestCase):
 
58
    encoding = 'shift_jisx0213'
 
59
    mapfilename = 'SHIFT_JISX0213.TXT'
 
60
    mapfileurl = 'http://people.freebsd.org/~perky/i18n/SHIFT_JISX0213.TXT'
 
61
 
 
62
 
 
63
def test_main():
 
64
    support.run_unittest(__name__)
 
65
 
 
66
if __name__ == "__main__":
 
67
    test_main()