MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / test_memoized_slots

Method test_memoized_slots

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

Source from the content-addressed store, hash-verified

665 eq_(val[0], 21)
666
667 def test_memoized_slots(self):
668 canary = mock.Mock()
669
670 class Foob(util.MemoizedSlots):
671 __slots__ = ("foo_bar", "gogo")
672
673 def _memoized_method_gogo(self):
674 canary.method()
675 return "gogo"
676
677 def _memoized_attr_foo_bar(self):
678 canary.attr()
679 return "foobar"
680
681 f1 = Foob()
682 assert_raises(AttributeError, setattr, f1, "bar", "bat")
683
684 eq_(f1.foo_bar, "foobar")
685
686 eq_(f1.foo_bar, "foobar")
687
688 eq_(f1.gogo(), "gogo")
689
690 eq_(f1.gogo(), "gogo")
691
692 eq_(canary.mock_calls, [mock.call.attr(), mock.call.method()])
693
694
695class WrapCallableTest(fixtures.TestBase):

Callers

nothing calls this directly

Calls 5

assert_raisesFunction · 0.90
eq_Function · 0.90
methodMethod · 0.80
FoobClass · 0.70
attrMethod · 0.45

Tested by

no test coverage detected