MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_memoized_property

Method test_memoized_property

test/base/test_utils.py:631–647  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

629
630class MemoizedAttrTest(fixtures.TestBase):
631 def test_memoized_property(self):
632 val = [20]
633
634 class Foo:
635 @util.memoized_property
636 def bar(self):
637 v = val[0]
638 val[0] += 1
639 return v
640
641 ne_(Foo.bar, None)
642 f1 = Foo()
643 assert "bar" not in f1.__dict__
644 eq_(f1.bar, 20)
645 eq_(f1.bar, 20)
646 eq_(val[0], 21)
647 eq_(f1.__dict__["bar"], 20)
648
649 def test_memoized_instancemethod(self):
650 val = [20]

Callers

nothing calls this directly

Calls 3

ne_Function · 0.90
eq_Function · 0.90
FooClass · 0.70

Tested by

no test coverage detected