1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/attributes3.py Sun Sep 28 21:42:03 2008 +0200
1.3 @@ -0,0 +1,41 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +class C:
1.7 + def g(self):
1.8 + return self.f # C.f with context self
1.9 + def f(self): pass
1.10 +
1.11 + def test(self):
1.12 + self.f()
1.13 + self.g()
1.14 +
1.15 +class D:
1.16 + f = C.f
1.17 + def g(self):
1.18 + return self.f # D.f with context preserved
1.19 +
1.20 + def test(self):
1.21 + self.f(2)
1.22 + self.g()
1.23 +
1.24 +class E(C):
1.25 + def g(self):
1.26 + return self.f # C.f with context self
1.27 +
1.28 + def test(self):
1.29 + self.f()
1.30 + self.g()
1.31 +
1.32 +C.f
1.33 +D.f
1.34 +E.f
1.35 +
1.36 +c = C()
1.37 +d = D()
1.38 +e = E()
1.39 +
1.40 +x = c.f # bound C.f == c.g()
1.41 +y = d.f # unbound C.f == d.g()
1.42 +z = e.f # bound E.f == e.g()
1.43 +
1.44 +# vim: tabstop=4 expandtab shiftwidth=4