| 1 |
# |
| 2 |
# test_codecmaps_jp.py |
| 3 |
# Codec mapping tests for Japanese encodings |
| 4 |
# |
| 5 |
|
| 6 |
from test import multibytecodec_support |
| 7 |
import unittest |
| 8 |
|
| 9 |
class TestCP932Map(multibytecodec_support.TestBase_Mapping, |
| 10 |
unittest.TestCase): |
| 11 |
encoding = 'cp932' |
| 12 |
mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT' |
| 13 |
supmaps = [ |
| 14 |
(b'\x80', '\u0080'), |
| 15 |
(b'\xa0', '\uf8f0'), |
| 16 |
(b'\xfd', '\uf8f1'), |
| 17 |
(b'\xfe', '\uf8f2'), |
| 18 |
(b'\xff', '\uf8f3'), |
| 19 |
] |
| 20 |
for i in range(0xa1, 0xe0): |
| 21 |
supmaps.append((bytes([i]), chr(i+0xfec0))) |
| 22 |
|
| 23 |
|
| 24 |
class TestEUCJPCOMPATMap(multibytecodec_support.TestBase_Mapping, |
| 25 |
unittest.TestCase): |
| 26 |
encoding = 'euc_jp' |
| 27 |
mapfilename = 'EUC-JP.TXT' |
| 28 |
mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT' |
| 29 |
|
| 30 |
|
| 31 |
class TestSJISCOMPATMap(multibytecodec_support.TestBase_Mapping, |
| 32 |
unittest.TestCase): |
| 33 |
encoding = 'shift_jis' |
| 34 |
mapfilename = 'SHIFTJIS.TXT' |
| 35 |
mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT' |
| 36 |
pass_enctest = [ |
| 37 |
(b'\x81_', '\\'), |
| 38 |
] |
| 39 |
pass_dectest = [ |
| 40 |
(b'\\', '\xa5'), |
| 41 |
(b'~', '\u203e'), |
| 42 |
(b'\x81_', '\\'), |
| 43 |
] |
| 44 |
|
| 45 |
class TestEUCJISX0213Map(multibytecodec_support.TestBase_Mapping, |
| 46 |
unittest.TestCase): |
| 47 |
encoding = 'euc_jisx0213' |
| 48 |
mapfilename = 'EUC-JISX0213.TXT' |
| 49 |
mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT' |
| 50 |
|
| 51 |
|
| 52 |
class TestSJISX0213Map(multibytecodec_support.TestBase_Mapping, |
| 53 |
unittest.TestCase): |
| 54 |
encoding = 'shift_jisx0213' |
| 55 |
mapfilename = 'SHIFT_JISX0213.TXT' |
| 56 |
mapfileurl = 'http://www.pythontest.net/unicode/SHIFT_JISX0213.TXT' |
| 57 |
|
| 58 |
|
| 59 |
if __name__ == "__main__": |
| 60 |
unittest.main() |