[Python-checkins] CVS: python/dist/src/Lib/test test_b1.py,1.43,1.44 test_b2.py,1.30,1.31

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 26 Feb 2002 14:39:25 -0800


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

Modified Files:
	test_b1.py test_b2.py 
Log Message:
SF patch #523169, by Samuele Pedroni.

There were never tests for the fact that list() always returns a *new*
list object, even when the argument is a list, while tuple() may
return a reference to the argument when it is a tuple.  Now there are.



Index: test_b1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** test_b1.py	29 Dec 2001 00:35:20 -0000	1.43
--- test_b1.py	26 Feb 2002 22:39:23 -0000	1.44
***************
*** 492,495 ****
--- 492,505 ----
  if len({'a':1, 'b': 2}) != 2: raise TestFailed, 'len({\'a\':1, \'b\': 2})'
  
+ print 'list'
+ if list([]) != []: raise TestFailed, 'list([])'
+ l0_3 = [0, 1, 2, 3]
+ l0_3_bis = list(l0_3)
+ if l0_3 != l0_3_bis or l0_3 is l0_3_bis: raise TestFailed, 'list([0, 1, 2, 3])'
+ if list(()) != []: raise TestFailed, 'list(())'
+ if list((0, 1, 2, 3)) != [0, 1, 2, 3]: raise TestFailed, 'list((0, 1, 2, 3))'
+ if list('') != []: raise TestFailed, 'list('')'
+ if list('spam') != ['s', 'p', 'a', 'm']: raise TestFailed, "list('spam')"
+ 
  print 'long'
  if long(314) != 314L: raise TestFailed, 'long(314)'

Index: test_b2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** test_b2.py	29 Dec 2001 00:16:09 -0000	1.30
--- test_b2.py	26 Feb 2002 22:39:23 -0000	1.31
***************
*** 254,258 ****
  print 'tuple'
  if tuple(()) != (): raise TestFailed, 'tuple(())'
! if tuple((0, 1, 2, 3)) != (0, 1, 2, 3): raise TestFailed, 'tuple((0, 1, 2, 3))'
  if tuple([]) != (): raise TestFailed, 'tuple([])'
  if tuple([0, 1, 2, 3]) != (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])'
--- 254,260 ----
  print 'tuple'
  if tuple(()) != (): raise TestFailed, 'tuple(())'
! t0_3 = (0, 1, 2, 3)
! t0_3_bis = tuple(t0_3)
! if t0_3 is not t0_3_bis: raise TestFailed, 'tuple((0, 1, 2, 3))'
  if tuple([]) != (): raise TestFailed, 'tuple([])'
  if tuple([0, 1, 2, 3]) != (0, 1, 2, 3): raise TestFailed, 'tuple([0, 1, 2, 3])'