diff --git a/django/utils/functional.py b/django/utils/functional.py
a
|
b
|
|
67 | 67 | cls.__dispatch = {} |
68 | 68 | for resultclass in resultclasses: |
69 | 69 | cls.__dispatch[resultclass] = {} |
70 | | for (k, v) in resultclass.__dict__.items(): |
71 | | # All __promise__ return the same wrapper method, but they |
72 | | # also do setup, inserting the method into the dispatch |
73 | | # dict. |
74 | | meth = cls.__promise__(resultclass, k, v) |
75 | | if hasattr(cls, k): |
76 | | continue |
77 | | setattr(cls, k, meth) |
| 70 | for type_ in reversed(resultclass.mro()): |
| 71 | for (k, v) in type_.__dict__.items(): |
| 72 | # All __promise__ return the same wrapper method, but they |
| 73 | # also do setup, inserting the method into the dispatch |
| 74 | # dict. |
| 75 | meth = cls.__promise__(resultclass, k, v) |
| 76 | if hasattr(cls, k): |
| 77 | continue |
| 78 | setattr(cls, k, meth) |
78 | 79 | cls._delegate_str = str in resultclasses |
79 | 80 | cls._delegate_unicode = unicode in resultclasses |
80 | 81 | assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call lazy() with both str and unicode return types." |
diff --git a/tests/regressiontests/utils/functional.py b/tests/regressiontests/utils/functional.py
a
|
b
|
|
1 | 1 | from django.utils import unittest |
2 | 2 | from django.utils.functional import lazy |
3 | | |
| 3 | from django.utils.datastructures import SortedDict |
4 | 4 | |
5 | 5 | class FunctionalTestCase(unittest.TestCase): |
6 | 6 | def test_lazy(self): |
7 | 7 | t = lazy(lambda: tuple(range(3)), list, tuple) |
8 | 8 | for a, b in zip(t(), range(3)): |
9 | 9 | self.assertEqual(a, b) |
| 10 | |
| 11 | def test_lazy_base_class(self): |
| 12 | """test that lazy also copy base class methods |
| 13 | in the proxy object""" |
| 14 | |
| 15 | class Base(object): |
| 16 | def base_method(self): |
| 17 | pass |
| 18 | |
| 19 | class Klazz(Base): |
| 20 | pass |
| 21 | |
| 22 | t = lazy(lambda: Klazz(), Klazz)() |
| 23 | self.assertTrue('base_method' in dir(t)) |