# HG changeset patch # User Paul Boddie # Date 1222630923 -7200 # Node ID 585f1b4330e009f763f1d2e913608043ad54ef4e # Parent 2c1ad8c1697d7035f801a1bac9c88b00cfe35b72 Split the attributes2 test into smaller pieces. diff -r 2c1ad8c1697d -r 585f1b4330e0 tests/attributes2.py --- a/tests/attributes2.py Sun Sep 28 21:27:01 2008 +0200 +++ b/tests/attributes2.py Sun Sep 28 21:42:03 2008 +0200 @@ -3,60 +3,25 @@ def e(x): pass class C: - def h(self): - self.m = self.f - return self.m # not known - def g(self): - return self.f # C.f with context self - def f(self): pass e = e def test(self): self.e() - self.f() - self.g() - self.h() class D: e = C.e - f = C.f - def g(self): - return self.f # D.f with context preserved - def h(self): - self.m = self.f - return self.m # not known def test(self): - self.e(1) - self.f(2) - self.g() - self.h() + self.e(1) # TypeError: unbound C.e needs C instance, not int class E(C): - def g(self): - return self.f # C.f with context self - def h(self): - self.m = self.f - return self.m # not known - def test(self): self.e() - self.f() - self.g() - self.h() - -C.f -D.f -E.f c = C() d = D() e = E() -x = c.f # bound C.f == c.h() == c.g() -y = d.f # unbound C.f == d.h() == d.g() -z = e.f # bound E.f == e.h() == e.g() - p = c.e # bound C.e q = d.e # unbound C.e r = e.e # bound E.e diff -r 2c1ad8c1697d -r 585f1b4330e0 tests/attributes3.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes3.py Sun Sep 28 21:42:03 2008 +0200 @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +class C: + def g(self): + return self.f # C.f with context self + def f(self): pass + + def test(self): + self.f() + self.g() + +class D: + f = C.f + def g(self): + return self.f # D.f with context preserved + + def test(self): + self.f(2) + self.g() + +class E(C): + def g(self): + return self.f # C.f with context self + + def test(self): + self.f() + self.g() + +C.f +D.f +E.f + +c = C() +d = D() +e = E() + +x = c.f # bound C.f == c.g() +y = d.f # unbound C.f == d.g() +z = e.f # bound E.f == e.g() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 2c1ad8c1697d -r 585f1b4330e0 tests/attributes4.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes4.py Sun Sep 28 21:42:03 2008 +0200 @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +class C: + def h(self): + self.m = self.f + return self.m # not known + def f(self): pass + + def test(self): + self.f() + self.h() + +class D: + f = C.f + def h(self): + self.m = self.f + return self.m # not known + + def test(self): + self.f(2) + self.h() + +class E(C): + def h(self): + self.m = self.f + return self.m # not known + + def test(self): + self.f() + self.h() + +c = C() +d = D() +e = E() + +x = c.f # bound C.f == c.h() +y = d.f # unbound C.f == d.h() +z = e.f # bound E.f == e.h() + +# vim: tabstop=4 expandtab shiftwidth=4