Skip to content

Commit 1eb6d27

Browse files
author
Victor Stinner
committed
(Merge 3.2) Issue #12057: Add tests for ISO 2022 codecs
iso2022_jp, iso2022_jp_2 and iso2022_kr
2 parents 4f1252d + ee49797 commit 1eb6d27

7 files changed

Lines changed: 80 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Python の開発は、1990 年ごろから開始されています。
2+
開発者の Guido van Rossum は教育用のプログラミング言語「ABC」の開発に参加していましたが、ABC は実用上の目的にはあまり適していませんでした。
3+
このため、Guido はより実用的なプログラミング言語の開発を開始し、英国 BBS 放送のコメディ番組「モンティ パイソン」のファンである Guido はこの言語を「Python」と名づけました。
4+
このような背景から生まれた Python の言語設計は、「シンプル」で「習得が容易」という目標に重点が置かれています。
5+
多くのスクリプト系言語ではユーザの目先の利便性を優先して色々な機能を言語要素として取り入れる場合が多いのですが、Python ではそういった小細工が追加されることはあまりありません。
6+
言語自体の機能は最小限に押さえ、必要な機能は拡張モジュールとして追加する、というのが Python のポリシーです。
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Python $B$N3+H/$O!"(B1990 $BG/$4$m$+$i3+;O$5$l$F$$$^$9!#(B
2+
$B3+H/<T$N(B Guido van Rossum $B$O650iMQ$N%W%m%0%i%_%s%08@8l!V(BABC$B!W$N3+H/$K;22C$7$F$$$^$7$?$,!"(BABC $B$O<BMQ>e$NL\E*$K$O$"$^$jE,$7$F$$$^$;$s$G$7$?!#(B
3+
$B$3$N$?$a!"(BGuido $B$O$h$j<BMQE*$J%W%m%0%i%_%s%08@8l$N3+H/$r3+;O$7!"1Q9q(B BBS $BJ|Aw$N%3%a%G%#HVAH!V%b%s%F%#(B $B%Q%$%=%s!W$N%U%!%s$G$"$k(B Guido $B$O$3$N8@8l$r!V(BPython$B!W$HL>$E$1$^$7$?!#(B
4+
$B$3$N$h$&$JGX7J$+$i@8$^$l$?(B Python $B$N8@8l@_7W$O!"!V%7%s%W%k!W$G!V=,F@$,MF0W!W$H$$$&L\I8$K=EE@$,CV$+$l$F$$$^$9!#(B
5+
$BB?$/$N%9%/%j%W%H7O8@8l$G$O%f!<%6$NL\@h$NMxJX@-$rM%@h$7$F?'!9$J5!G=$r8@8lMWAG$H$7$F<h$jF~$l$k>l9g$,B?$$$N$G$9$,!"(BPython $B$G$O$=$&$$$C$?>.:Y9)$,DI2C$5$l$k$3$H$O$"$^$j$"$j$^$;$s!#(B
6+
$B8@8l<+BN$N5!G=$O:G>.8B$K2!$5$(!"I,MW$J5!G=$O3HD%%b%8%e!<%k$H$7$FDI2C$9$k!"$H$$$&$N$,(B Python $B$N%]%j%7!<$G$9!#(B
7+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
◎ 파이썬(Python)은 배우기 쉽고, 강력한 프로그래밍 언어입니다. 파이썬은
2+
효율적인 고수준 데이터 구조와 간단하지만 효율적인 객체지향프로그래밍을
3+
지원합니다. 파이썬의 우아(優雅)한 문법과 동적 타이핑, 그리고 인터프리팅
4+
환경은 파이썬을 스크립팅과 여러 분야에서와 대부분의 플랫폼에서의 빠른
5+
애플리케이션 개발을 할 수 있는 이상적인 언어로 만들어줍니다.
6+
7+
☆첫가끝: 날아라 쓩~ 큼! 금없이 전니다. 그런거 다.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$)C!] FD@L=c(Python)@: 9h?l1b =10m, 0-7BGQ GA7N1W7!9V >p>n@T4O4Y. FD@L=c@:
2+
H?@2@{@N 0m<vAX 5%@LEM 18A6?M 0#4\GOAv88 H?@2@{@N 04C<AvGbGA7N1W7!9V@;
3+
Av?xGU4O4Y. FD@L=c@G ?l>F(iPd:)GQ 9.9}0z 5?@{ E8@LGN, 1W8.0m @NEMGA8.FC
4+
H/0f@: FD@L=c@; =:E)83FC0z ?)7/ :P>_?!<-?M 4k:N:P@G GC7'F{?!<-@G :|8%
5+
>VGC8.DI@L<G 039_@; GR <v @V4B @L;s@{@N >p>n7N 885i>nA]4O4Y.
6+
7+
!YC90!3!: 3/>F6s >1~ E-! 1]>x@L @|4O4Y. 1W710E 4Y.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
#
3+
# Codec encoding tests for ISO 2022 encodings.
4+
5+
from test import support
6+
from test import test_multibytecodec_support
7+
import unittest
8+
9+
COMMON_CODEC_TESTS = (
10+
# invalid bytes
11+
(b'ab\xFFcd', 'replace', 'ab\uFFFDcd'),
12+
(b'ab\x1Bdef', 'replace', 'ab\x1Bdef'),
13+
(b'ab\x1B$def', 'replace', 'ab\uFFFD'),
14+
)
15+
16+
class Test_ISO2022_JP(test_multibytecodec_support.TestBase, unittest.TestCase):
17+
encoding = 'iso2022_jp'
18+
tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
19+
codectests = COMMON_CODEC_TESTS + (
20+
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
21+
)
22+
23+
class Test_ISO2022_JP2(test_multibytecodec_support.TestBase, unittest.TestCase):
24+
encoding = 'iso2022_jp_2'
25+
tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
26+
codectests = COMMON_CODEC_TESTS + (
27+
(b'ab\x1BNdef', 'replace', 'abdef'),
28+
)
29+
30+
class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
31+
encoding = 'iso2022_kr'
32+
tstring = test_multibytecodec_support.load_teststring('iso2022_kr')
33+
codectests = COMMON_CODEC_TESTS + (
34+
(b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
35+
)
36+
37+
# iso2022_kr.txt cannot be used to test "chunk coding": the escape
38+
# sequence is only written on the first line
39+
def test_chunkcoding(self):
40+
pass
41+
42+
def test_main():
43+
support.run_unittest(__name__)
44+
45+
if __name__ == "__main__":
46+
test_main()

Lib/test/test_multibytecodec_support.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def test_errorhandle(self):
6060
self.assertTrue(type(result) is str, type(result))
6161
else:
6262
self.assertTrue(type(result) is bytes, type(result))
63-
self.assertEqual(result, expected)
63+
self.assertEqual(result, expected,
64+
'%a.decode(%r)=%a != %a'
65+
% (source, self.encoding, result, expected))
6466
else:
6567
self.assertRaises(UnicodeError, func, source, scheme)
6668

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ Extension Modules
785785
Tests
786786
-----
787787

788+
- Issue #12057: Add tests for ISO 2022 codecs (iso2022_jp, iso2022_jp_2,
789+
iso2022_kr).
790+
788791
- Issue #12180: Fixed a few remaining errors in test_packaging when no
789792
threading.
790793

0 commit comments

Comments
 (0)