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

M.-A. Lemburg lemburg@users.sourceforge.net
Thu, 20 Sep 2001 05:53:18 -0700


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

Modified Files:
	test_unicode.py 
Log Message:
Implement the changes proposed in patch #413333. unicode(obj) now
works just like str(obj) in that it tries __str__/tp_str on the object
in case it finds that the object is not a string or buffer.



Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** test_unicode.py	2001/09/20 10:35:45	1.37
--- test_unicode.py	2001/09/20 12:53:13	1.38
***************
*** 430,433 ****
--- 430,434 ----
  verify(unicode('hello','latin-1') == u'hello')
  
+ # Compatibility to str():
  class String:
      x = ''
***************
*** 445,448 ****
--- 446,453 ----
  verify(str(o) == 'abc')
  
+ for obj in (123, 123.45, 123L):
+     verify(unicode(obj) == unicode(str(obj)))
+ 
+ # Error handling
  try:
      u'Andr\202 x'.encode('ascii')