MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_memoized_property

Method test_memoized_property

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

Source from the content-addressed store, hash-verified

534
535class MemoizedAttrTest(fixtures.TestBase):
536 def test_memoized_property(self):
537 val = [20]
538
539 class Foo:
540 @util.memoized_property
541 def bar(self):
542 v = val[0]
543 val[0] += 1
544 return v
545
546 ne_(Foo.bar, None)
547 f1 = Foo()
548 assert "bar" not in f1.__dict__
549 eq_(f1.bar, 20)
550 eq_(f1.bar, 20)
551 eq_(val[0], 21)
552 eq_(f1.__dict__["bar"], 20)
553
554 def test_memoized_instancemethod(self):
555 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