Verify two linked traitlets can be unlinked and relinked.
(self)
| 2072 | self.assertEqual(a.value, b.count) |
| 2073 | |
| 2074 | def test_unlink_link(self): |
| 2075 | """Verify two linked traitlets can be unlinked and relinked.""" |
| 2076 | |
| 2077 | # Create two simple classes with Int traitlets. |
| 2078 | class A(HasTraits): |
| 2079 | value = Int() |
| 2080 | |
| 2081 | a = A(value=9) |
| 2082 | b = A(value=8) |
| 2083 | |
| 2084 | # Connect the two classes. |
| 2085 | c = link((a, "value"), (b, "value")) |
| 2086 | a.value = 4 |
| 2087 | c.unlink() |
| 2088 | |
| 2089 | # Change one of the values to make sure they don't stay in sync. |
| 2090 | a.value = 5 |
| 2091 | self.assertNotEqual(a.value, b.value) |
| 2092 | c.link() |
| 2093 | self.assertEqual(a.value, b.value) |
| 2094 | a.value += 1 |
| 2095 | self.assertEqual(a.value, b.value) |
| 2096 | |
| 2097 | def test_callbacks(self): |
| 2098 | """Verify two linked traitlets have their callbacks called once.""" |