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

Finn Bock bckfnn@users.sourceforge.net
Mon, 10 Dec 2001 12:57:37 -0800


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

Modified Files:
	test_unicode.py 
Log Message:
Skipping some tests by adding the usual jython conditional test around: 

- the repr of unicode. Jython only add the u'' if the string contains char
  values > 255. 
- A unicode arg to unicode() is perfectly valid in jython. 
- A test buffer() test. No buffer() on Jython

This closes patch "[ #490920 ] Jython and test_unicode".



Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** test_unicode.py	2001/12/01 04:11:16	1.46
--- test_unicode.py	2001/12/10 20:57:34	1.47
***************
*** 9,27 ****
  import sys
  
! # Test basic sanity of repr()
! verify(repr(u'abc') == "u'abc'")
! verify(repr(u'ab\\c') == "u'ab\\\\c'")
! verify(repr(u'ab\\') == "u'ab\\\\'")
! verify(repr(u'\\c') == "u'\\\\c'")
! verify(repr(u'\\') == "u'\\\\'")
! verify(repr(u'\n') == "u'\\n'")
! verify(repr(u'\r') == "u'\\r'")
! verify(repr(u'\t') == "u'\\t'")
! verify(repr(u'\b') == "u'\\x08'")
! verify(repr(u"'\"") == """u'\\'"'""")
! verify(repr(u"'\"") == """u'\\'"'""")
! verify(repr(u"'") == '''u"'"''')
! verify(repr(u'"') == """u'"'""")
! verify(repr(u''.join(map(unichr, range(256)))) ==
         "u'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
         "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
--- 9,28 ----
  import sys
  
! if not sys.platform.startswith('java'):
!     # Test basic sanity of repr()
!     verify(repr(u'abc') == "u'abc'")
!     verify(repr(u'ab\\c') == "u'ab\\\\c'")
!     verify(repr(u'ab\\') == "u'ab\\\\'")
!     verify(repr(u'\\c') == "u'\\\\c'")
!     verify(repr(u'\\') == "u'\\\\'")
!     verify(repr(u'\n') == "u'\\n'")
!     verify(repr(u'\r') == "u'\\r'")
!     verify(repr(u'\t') == "u'\\t'")
!     verify(repr(u'\b') == "u'\\x08'")
!     verify(repr(u"'\"") == """u'\\'"'""")
!     verify(repr(u"'\"") == """u'\\'"'""")
!     verify(repr(u"'") == '''u"'"''')
!     verify(repr(u'"') == """u'"'""")
!     verify(repr(u''.join(map(unichr, range(256)))) ==
         "u'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
         "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
***************
*** 447,463 ****
  # PyUnicode_FromEncodedObject() at C level)
  
! try:
!     unicode(u'decoding unicode is not supported', 'utf-8', 'strict')
! except TypeError:
!     pass
! else:
!     raise TestFailed, "decoding unicode should NOT be supported"
  
  verify(unicode('strings are decoded to unicode', 'utf-8', 'strict')
         == u'strings are decoded to unicode')
  
! verify(unicode(buffer('character buffers are decoded to unicode'),
!                'utf-8', 'strict')
!        == u'character buffers are decoded to unicode')
  
  print 'done.'
--- 448,466 ----
  # PyUnicode_FromEncodedObject() at C level)
  
! if not sys.platform.startswith('java'):
!     try:
!         unicode(u'decoding unicode is not supported', 'utf-8', 'strict')
!     except TypeError:
!         pass
!     else:
!         raise TestFailed, "decoding unicode should NOT be supported"
  
  verify(unicode('strings are decoded to unicode', 'utf-8', 'strict')
         == u'strings are decoded to unicode')
  
! if not sys.platform.startswith('java'):
!     verify(unicode(buffer('character buffers are decoded to unicode'),
!                    'utf-8', 'strict')
!            == u'character buffers are decoded to unicode')
  
  print 'done.'