MCPcopy Create free account
hub / github.com/ipython/traitlets / test_notify_subclass

Method test_notify_subclass

tests/test_traitlets.py:687–706  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

685 self.assertEqual(b.b, 100.0)
686
687 def test_notify_subclass(self):
688 class A(HasTraits):
689 a = Int()
690
691 class B(A):
692 b = Float()
693
694 b = B()
695 b.observe(self.notify1, "a")
696 b.observe(self.notify2, "b")
697 b.a = 0
698 b.b = 0.0
699 self.assertEqual(len(self._notify1), 0)
700 self.assertEqual(len(self._notify2), 0)
701 b.a = 10
702 b.b = 10.0
703 change = change_dict("a", 0, 10, b, "change")
704 self.assertTrue(change in self._notify1)
705 change = change_dict("b", 0.0, 10.0, b, "change")
706 self.assertTrue(change in self._notify2)
707
708 def test_static_notify(self):
709 class A(HasTraits):

Callers

nothing calls this directly

Calls 3

change_dictFunction · 0.85
observeMethod · 0.80
BClass · 0.70

Tested by

no test coverage detected