summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-15 17:51:17 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-15 17:51:17 (GMT)
commitb5a136b05d1352faf5f9745a033d9af61bbe74a0 (patch)
tree896ccf251553562d841a569dfd86069ec4da18fc /Lib
parentf95dd0a2986392d4f51bb1dd17db50ff40aa90d5 (diff)
downloadcpython-b5a136b05d1352faf5f9745a033d9af61bbe74a0.zip
cpython-b5a136b05d1352faf5f9745a033d9af61bbe74a0.tar.gz
cpython-b5a136b05d1352faf5f9745a033d9af61bbe74a0.tar.bz2
Add a test to verify that bound methods work correctly.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index e461526..78da9dc 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -847,6 +847,23 @@ def overloading():
del a[0:10]
verify(a.delslice == (0, 10))
+def methods():
+ if verbose: print "testing methods..."
+ class C(object):
+ def __init__(self, x):
+ self.x = x
+ def foo(self):
+ return self.x
+ c1 = C(1)
+ verify(c1.foo() == 1)
+ class D(C):
+ boo = C.foo
+ goo = c1.foo
+ d2 = D(2)
+ verify(d2.foo() == 2)
+ verify(d2.boo() == 2)
+ verify(d2.goo() == 2)
+
def all():
lists()
dicts()
@@ -873,6 +890,7 @@ def all():
newslot()
altmro()
overloading()
+ methods()
all()