[Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.36,1.37

M.-A. Lemburg lemburg@users.sourceforge.net
Thu, 20 Sep 2001 03:35:48 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv17012/Lib/test

Modified Files:
	test_unicode.py 
Log Message:
Patch #435971: UTF-7 codec by Brian Quinlan.



Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** test_unicode.py	2001/07/25 16:05:58	1.36
--- test_unicode.py	2001/09/20 10:35:45	1.37
***************
*** 378,381 ****
--- 378,407 ----
  print 'Testing builtin codecs...',
  
+ # UTF-7 specific encoding tests:
+ utfTests = [(u'A\u2262\u0391.', 'A+ImIDkQ.'),  # RFC2152 example
+  (u'Hi Mom -\u263a-!', 'Hi Mom -+Jjo--!'),     # RFC2152 example
+  (u'\u65E5\u672C\u8A9E', '+ZeVnLIqe-'),        # RFC2152 example
+  (u'Item 3 is \u00a31.', 'Item 3 is +AKM-1.'), # RFC2152 example
+  (u'+', '+-'),
+  (u'+-', '+--'),
+  (u'+?', '+-?'),
+  (u'\?', '+AFw?'),
+  (u'+?', '+-?'),
+  (ur'\\?', '+AFwAXA?'),
+  (ur'\\\?', '+AFwAXABc?'),
+  (ur'++--', '+-+---')]
+ 
+ for x,y in utfTests:
+     verify( x.encode('utf-7') == y )
+ 
+ try:        
+     unicode('+3ADYAA-', 'utf-7') # surrogates not supported
+ except UnicodeError:
+     pass
+ else:
+     raise TestFailed, "unicode('+3ADYAA-', 'utf-7') failed to raise an exception"
+ 
+ verify(unicode('+3ADYAA-', 'utf-7', 'replace') == u'\ufffd')
+ 
  # UTF-8 specific encoding tests:
  verify(u'\u20ac'.encode('utf-8') == \
***************
*** 440,443 ****
--- 466,470 ----
  
  verify(u'hello'.encode('ascii') == 'hello')
+ verify(u'hello'.encode('utf-7') == 'hello')
  verify(u'hello'.encode('utf-8') == 'hello')
  verify(u'hello'.encode('utf8') == 'hello')
***************
*** 448,452 ****
  # 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)
--- 475,479 ----
  # Roundtrip safety for BMP (just the first 1024 chars)
  u = u''.join(map(unichr, range(1024)))
! for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
                   'raw_unicode_escape', 'unicode_escape', 'unicode_internal'):
      verify(unicode(u.encode(encoding),encoding) == u)