[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.1.2.22,1.1.2.23
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 29 Jun 2001 09:38:40 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv27651
Modified Files:
Tag: descr-branch
test_descr.py
Log Message:
Add some tests for subclassing spam.spamlist and spam.spamdict, since
this ability was just added.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/Attic/test_descr.py,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -C2 -r1.1.2.22 -r1.1.2.23
*** test_descr.py 2001/06/29 16:32:45 1.1.2.22
--- test_descr.py 2001/06/29 16:38:38 1.1.2.23
***************
*** 241,244 ****
--- 241,255 ----
testset3op(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]),
spamlist([1,5,6,4]), "a[b:c]=d", "__setslice__")
+ # Test subclassing
+ class C(spam.spamlist):
+ def foo(self): return 1
+ a = C()
+ verify(a == [])
+ verify(a.foo() == 1)
+ a.append(100)
+ verify(a == [100])
+ verify(a.getstate() == 0)
+ a.setstate(42)
+ verify(a.getstate() == 42)
def spamdicts():
***************
*** 273,276 ****
--- 284,298 ----
testset2op(spamdict({1:2,3:4}), 2, 3, spamdict({1:2,2:3,3:4}),
"a[b]=c", "__setitem__")
+ # Test subclassing
+ class C(spam.spamdict):
+ def foo(self): return 1
+ a = C()
+ verify(a.items() == [])
+ verify(a.foo() == 1)
+ a['foo'] = 'bar'
+ verify(a.items() == [('foo', 'bar')])
+ verify(a.getstate() == 0)
+ a.setstate(100)
+ verify(a.getstate() == 100)
def pydicts():