summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-05-04 18:56:13 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-05-04 18:56:13 (GMT)
commit244651aa2f21db5006bbdc013d2586cbc10b313d (patch)
treed3676bec7e1efd55db9bfc10e02a9e9f5939de25 /Lib/test/test_unicode.py
parent375c01973881076b13d7d08afcd0b06b2a7690ce (diff)
downloadcpython-244651aa2f21db5006bbdc013d2586cbc10b313d.zip
cpython-244651aa2f21db5006bbdc013d2586cbc10b313d.tar.gz
cpython-244651aa2f21db5006bbdc013d2586cbc10b313d.tar.bz2
Merged revisions 72283-72284 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72283 | antoine.pitrou | 2009-05-04 20:32:32 +0200 (lun., 04 mai 2009) | 4 lines Issue #4426: The UTF-7 decoder was too strict and didn't accept some legal sequences. Patch by Nick Barnes and Victor Stinner. ........ r72284 | antoine.pitrou | 2009-05-04 20:32:50 +0200 (lun., 04 mai 2009) | 3 lines Add Nick Barnes to ACKS. ........
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 220a8eb..21bb922 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -867,19 +867,31 @@ class UnicodeTest(
('+?', b'+-?'),
(r'\\?', b'+AFwAXA?'),
(r'\\\?', b'+AFwAXABc?'),
- (r'++--', b'+-+---')
+ (r'++--', b'+-+---'),
+ ('\U000abcde', b'+2m/c3g-'), # surrogate pairs
+ ('/', b'/'),
]
for (x, y) in utfTests:
self.assertEqual(x.encode('utf-7'), y)
- # surrogates not supported
+ # Unpaired surrogates not supported
self.assertRaises(UnicodeError, str, b'+3ADYAA-', 'utf-7')
- self.assertEqual(str(b'+3ADYAA-', 'utf-7', 'replace'), '\ufffd')
+ self.assertEqual(str(b'+3ADYAA-', 'utf-7', 'replace'), '\ufffd\ufffd')
# Issue #2242: crash on some Windows/MSVC versions
- self.assertRaises(UnicodeDecodeError, b'+\xc1'.decode, 'utf-7')
+ self.assertEqual(b'+\xc1'.decode('utf-7'), '\xc1')
+
+ # Direct encoded characters
+ set_d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'(),-./:?"
+ # Optional direct characters
+ set_o = '!"#$%&*;<=>@[]^_`{|}'
+ for c in set_d:
+ self.assertEqual(c.encode('utf7'), c.encode('ascii'))
+ self.assertEqual(c.encode('ascii').decode('utf7'), c)
+ for c in set_o:
+ self.assertEqual(c.encode('ascii').decode('utf7'), c)
def test_codecs_utf8(self):
self.assertEqual(''.encode('utf-8'), b'')