]> granicus.if.org Git - python/commitdiff
Add a test to verify that bound methods work correctly.
authorGuido van Rossum <guido@python.org>
Wed, 15 Aug 2001 17:51:17 +0000 (17:51 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 15 Aug 2001 17:51:17 +0000 (17:51 +0000)
Lib/test/test_descr.py

index e4615260220a0d88e6a9a8d4e0eae32214df0944..78da9dc9b53b0d9f0fe0ab1d3beeb271677d63b2 100644 (file)
@@ -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()