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

Method test_notify_all

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

Source from the content-addressed store, hash-verified

631 self._notify2.append(change)
632
633 def test_notify_all(self):
634 class A(HasTraits):
635 a = Int()
636 b = Float()
637
638 a = A()
639 a.observe(self.notify1)
640 a.a = 0
641 self.assertEqual(len(self._notify1), 0)
642 a.b = 0.0
643 self.assertEqual(len(self._notify1), 0)
644 a.a = 10
645 change = change_dict("a", 0, 10, a, "change")
646 self.assertTrue(change in self._notify1)
647 a.b = 10.0
648 change = change_dict("b", 0.0, 10.0, a, "change")
649 self.assertTrue(change in self._notify1)
650 self.assertRaises(TraitError, setattr, a, "a", "bad string")
651 self.assertRaises(TraitError, setattr, a, "b", "bad string")
652 self._notify1 = []
653 a.unobserve(self.notify1)
654 a.a = 20
655 a.b = 20.0
656 self.assertEqual(len(self._notify1), 0)
657
658 def test_notify_one(self):
659 class A(HasTraits):

Callers

nothing calls this directly

Calls 4

change_dictFunction · 0.85
observeMethod · 0.80
unobserveMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected