Verify two traitlets of the same type can be linked together using link.
(self)
| 2025 | |
| 2026 | class TestLink(TestCase): |
| 2027 | def test_connect_same(self): |
| 2028 | """Verify two traitlets of the same type can be linked together using link.""" |
| 2029 | |
| 2030 | # Create two simple classes with Int traitlets. |
| 2031 | class A(HasTraits): |
| 2032 | value = Int() |
| 2033 | |
| 2034 | a = A(value=9) |
| 2035 | b = A(value=8) |
| 2036 | |
| 2037 | # Connect the two classes. |
| 2038 | c = link((a, "value"), (b, "value")) |
| 2039 | |
| 2040 | # Make sure the values are the same at the point of linking. |
| 2041 | self.assertEqual(a.value, b.value) |
| 2042 | |
| 2043 | # Change one of the values to make sure they stay in sync. |
| 2044 | a.value = 5 |
| 2045 | self.assertEqual(a.value, b.value) |
| 2046 | b.value = 6 |
| 2047 | self.assertEqual(a.value, b.value) |
| 2048 | |
| 2049 | def test_link_different(self): |
| 2050 | """Verify two traitlets of different types can be linked together using link.""" |