diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-06-19 14:08:20 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-06-19 14:08:20 -0400 |
| commit | 0adf381d994b0f374d2b6394bff5f2c423942c78 (patch) | |
| tree | e7a5875c43a6e9f7a96773d4f232a364b2bb9959 /test/base/test_utils.py | |
| parent | 77c3bb26c29c491c1094427345ca51f309938572 (diff) | |
| download | sqlalchemy-0adf381d994b0f374d2b6394bff5f2c423942c78.tar.gz | |
- Fixed @memoized_property and @memoized_instancemethod
decorators so that Sphinx documentation picks up
these attributes and methods, such as
ResultProxy.inserted_primary_key. [ticket:1830]
Diffstat (limited to 'test/base/test_utils.py')
| -rw-r--r-- | test/base/test_utils.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index f9888ef0c..68ccc6ba2 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -83,6 +83,40 @@ class FrozenDictTest(TestBase): for loads, dumps in picklers(): print loads(dumps(d)) + +class MemoizedAttrTest(TestBase): + def test_memoized_property(self): + val = [20] + class Foo(object): + @util.memoized_property + def bar(self): + v = val[0] + val[0] += 1 + return v + + ne_(Foo.bar, None) + f1 = Foo() + assert 'bar' not in f1.__dict__ + eq_(f1.bar, 20) + eq_(f1.bar, 20) + eq_(val[0], 21) + eq_(f1.__dict__['bar'] , 20) + + def test_memoized_instancemethod(self): + val = [20] + class Foo(object): + @util.memoized_instancemethod + def bar(self): + v = val[0] + val[0] += 1 + return v + + ne_(Foo.bar, None) + f1 = Foo() + assert 'bar' not in f1.__dict__ + eq_(f1.bar(), 20) + eq_(f1.bar(), 20) + eq_(val[0], 21) class ColumnCollectionTest(TestBase): def test_in(self): |
