Commit 93018760 authored by Guido van Rossum's avatar Guido van Rossum

classic(), methods(): add another test relating to unbound methods:

when an unbound method of class A is stored as a class variable of
class B, and class B is *not* a subclass of class A, that method
should *not* get bound to B instances.
parent cdf0d758
...@@ -760,6 +760,9 @@ def classic(): ...@@ -760,6 +760,9 @@ def classic():
verify(d.goo(1) == (D, 1)) verify(d.goo(1) == (D, 1))
verify(d.foo(1) == (d, 1)) verify(d.foo(1) == (d, 1))
verify(D.foo(d, 1) == (d, 1)) verify(D.foo(d, 1) == (d, 1))
class E: # *not* subclassing from C
foo = C.foo
verify(E().foo == C.foo) # i.e., unbound
def compattr(): def compattr():
if verbose: print "Testing computed attributes..." if verbose: print "Testing computed attributes..."
...@@ -901,6 +904,9 @@ def methods(): ...@@ -901,6 +904,9 @@ def methods():
verify(d2.foo() == 2) verify(d2.foo() == 2)
verify(d2.boo() == 2) verify(d2.boo() == 2)
verify(d2.goo() == 1) verify(d2.goo() == 1)
class E(object):
foo = C.foo
verify(E().foo == C.foo) # i.e., unbound
def specials(): def specials():
# Test operators like __hash__ for which a built-in default exists # Test operators like __hash__ for which a built-in default exists
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment