diff options
author | Damien George <damien.p.george@gmail.com> | 2015-12-09 17:30:01 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-12-09 17:30:01 +0000 |
commit | 3ff259a262a6619325211909bbf3781538232b6f (patch) | |
tree | d87d2a2d6af086b098872806783123fd463aa7f1 /tests/basics | |
parent | 1be0fde45c8d84eaf04851af96f06aad8171b2b2 (diff) | |
download | micropython-3ff259a262a6619325211909bbf3781538232b6f.tar.gz micropython-3ff259a262a6619325211909bbf3781538232b6f.zip |
py: Fix calling of parent classmethod from instance of subclass.
Addresses issue #1697.
Diffstat (limited to 'tests/basics')
-rw-r--r-- | tests/basics/subclass_classmethod.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/basics/subclass_classmethod.py b/tests/basics/subclass_classmethod.py index 01deffba47..ae5fbd1aa3 100644 --- a/tests/basics/subclass_classmethod.py +++ b/tests/basics/subclass_classmethod.py @@ -10,3 +10,22 @@ class Sub(Base): Sub.foo() + +# overriding a member and accessing it via a classmethod + +class A(object): + foo = 0 + + @classmethod + def bar(cls): + print(cls.foo) + + def baz(self): + print(self.foo) + +class B(A): + foo = 1 + +B.bar() # class calling classmethod +B().bar() # instance calling classmethod +B().baz() # instance calling normal method |