(self)
| 706 | self.assertTrue(change in self._notify2) |
| 707 | |
| 708 | def test_static_notify(self): |
| 709 | class A(HasTraits): |
| 710 | a = Int() |
| 711 | b = Int() |
| 712 | _notify1 = [] |
| 713 | _notify_any = [] |
| 714 | |
| 715 | @observe("a") |
| 716 | def _a_changed(self, change): |
| 717 | self._notify1.append(change) |
| 718 | |
| 719 | @observe(All) |
| 720 | def _any_changed(self, change): |
| 721 | self._notify_any.append(change) |
| 722 | |
| 723 | a = A() |
| 724 | a.a = 0 |
| 725 | self.assertEqual(len(a._notify1), 0) |
| 726 | a.a = 10 |
| 727 | change = change_dict("a", 0, 10, a, "change") |
| 728 | self.assertTrue(change in a._notify1) |
| 729 | a.b = 1 |
| 730 | self.assertEqual(len(a._notify_any), 2) |
| 731 | change = change_dict("b", 0, 1, a, "change") |
| 732 | self.assertTrue(change in a._notify_any) |
| 733 | |
| 734 | class B(A): |
| 735 | b = Float() # type:ignore |
| 736 | _notify2 = [] |
| 737 | |
| 738 | @observe("b") |
| 739 | def _b_changed(self, change): |
| 740 | self._notify2.append(change) |
| 741 | |
| 742 | b = B() |
| 743 | b.a = 10 |
| 744 | b.b = 10.0 # type:ignore |
| 745 | change = change_dict("a", 0, 10, b, "change") |
| 746 | self.assertTrue(change in b._notify1) |
| 747 | change = change_dict("b", 0.0, 10.0, b, "change") |
| 748 | self.assertTrue(change in b._notify2) |
| 749 | |
| 750 | def test_notify_args(self): |
| 751 | def callback0(): |
nothing calls this directly
no test coverage detected