[Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.34,1.35
M.-A. Lemburg
lemburg@users.sourceforge.net
Fri, 20 Jul 2001 10:39:13 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv2536/Lib/test
Modified Files:
test_unicode.py
Log Message:
Make the unicode-escape and the UTF-16 codecs handle surrogates
correctly and thus roundtrip-safe.
Some minor cleanups of the code.
Added tests for the roundtrip-safety.
Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** test_unicode.py 2001/06/27 06:28:56 1.34
--- test_unicode.py 2001/07/20 17:39:11 1.35
***************
*** 446,451 ****
--- 446,459 ----
verify(u'hello'.encode('latin-1') == 'hello')
+ # Roundtrip safety for BMP (just the first 1024 chars)
u = u''.join(map(unichr, range(1024)))
for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
+ 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'):
+ verify(unicode(u.encode(encoding),encoding) == u)
+
+ # Roundtrip safety for non-BMP (just a few chars)
+ u = u'\U00010001\U00020002\U00030003\U00040004\U00050005'
+ for encoding in ('utf-8',
+ 'utf-16', 'utf-16-le', 'utf-16-be',
'raw_unicode_escape', 'unicode_escape', 'unicode_internal'):
verify(unicode(u.encode(encoding),encoding) == u)