[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.1.2.18,1.1.2.19

Guido van Rossum gvanrossum@users.sourceforge.net
Thu, 28 Jun 2001 13:35:33 -0700


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

Modified Files:
      Tag: descr-branch
	test_descr.py 
Log Message:
Add a test that overrides some list methods and verifies that they are
called properly.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/Attic/test_descr.py,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -C2 -r1.1.2.18 -r1.1.2.19
*** test_descr.py	2001/06/28 19:52:43	1.1.2.18
--- test_descr.py	2001/06/28 20:35:31	1.1.2.19
***************
*** 328,331 ****
--- 328,345 ----
              verify(a[i][j] == i*j)
  
+ def pylists():
+     if verbose: print "Testing Python subclass of list..."
+     class C(list):
+         def __getitem__(self, i):
+             return list.__getitem__(self, i) + 100
+         def __getslice__(self, i, j):
+             return (i, j)
+     a = C()
+     a.extend([0,1,2])
+     verify(a[0] == 100)
+     verify(a[1] == 101)
+     verify(a[2] == 102)
+     verify(a[100:200] == (100,200))
+ 
  def metaclass():
      if verbose: print "Testing __metaclass__..."
***************
*** 551,554 ****
--- 565,569 ----
      spamdicts()
      pydicts()
+     pylists()
      metaclass()
      pymods()