# HG changeset patch # User Paul Boddie # Date 1259455606 -3600 # Node ID 089a32b3936cfb816bbbabb1ec3f93c715588cca # Parent d441ffe22d9b7a0dbf90032fd69c9ddd56f40871 Added tests of class attribute behaviour, including a test of "foreign" class attributes accessed via self. diff -r d441ffe22d9b -r 089a32b3936c tests/attributes_class_from_other_class_via_self.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes_class_from_other_class_via_self.py Sun Nov 29 01:46:46 2009 +0100 @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +class C: + def f(self): + return 1 + +class D: + f = C.f + + def g(self, c): + m = self.f + return m(c) + +c = C() +d = D() +result_1 = d.g(c) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r d441ffe22d9b -r 089a32b3936c tests/attributes_class_used_by_superclass.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes_class_used_by_superclass.py Sun Nov 29 01:46:46 2009 +0100 @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +class C: + def f(self): + return self.x + +class D(C): + x = 456 + +d = D() +result_456 = d.f() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r d441ffe22d9b -r 089a32b3936c tests/attributes_instance_used_by_superclass.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/attributes_instance_used_by_superclass.py Sun Nov 29 01:46:46 2009 +0100 @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +class C: + def f(self): + return self.x + +class D(C): + def __init__(self): + self.x = 456 + +d = D() +result_456 = d.f() + +# vim: tabstop=4 expandtab shiftwidth=4