[Python-checkins] CVS: python/dist/src/Lib/test test_b1.py,1.42,1.42.4.1 test_b2.py,1.29,1.29.6.1

Michael Hudson mwh@users.sourceforge.net
Thu, 28 Feb 2002 02:14:26 -0800


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

Modified Files:
      Tag: release22-maint
	test_b1.py test_b2.py 
Log Message:
backport gvanrossum's checkin of
    revision 1.44 of test_b1.py
    revision 1.31 of test_b2.py

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.42
retrieving revision 1.42.4.1
diff -C2 -d -r1.42 -r1.42.4.1
*** test_b1.py	13 Dec 2001 19:52:03 -0000	1.42
--- test_b1.py	28 Feb 2002 10:14:24 -0000	1.42.4.1
***************
*** 477,480 ****
--- 477,490 ----
  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.29
retrieving revision 1.29.6.1
diff -C2 -d -r1.29 -r1.29.6.1
*** test_b2.py	7 Dec 2001 18:21:56 -0000	1.29
--- test_b2.py	28 Feb 2002 10:14:24 -0000	1.29.6.1
***************
*** 234,238 ****
  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])'
--- 234,240 ----
  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])'