Verify two traitlets of the same type can be linked together using directional_link.
(self)
| 2190 | |
| 2191 | class TestDirectionalLink(TestCase): |
| 2192 | def test_connect_same(self): |
| 2193 | """Verify two traitlets of the same type can be linked together using directional_link.""" |
| 2194 | |
| 2195 | # Create two simple classes with Int traitlets. |
| 2196 | class A(HasTraits): |
| 2197 | value = Int() |
| 2198 | |
| 2199 | a = A(value=9) |
| 2200 | b = A(value=8) |
| 2201 | |
| 2202 | # Connect the two classes. |
| 2203 | c = directional_link((a, "value"), (b, "value")) |
| 2204 | |
| 2205 | # Make sure the values are the same at the point of linking. |
| 2206 | self.assertEqual(a.value, b.value) |
| 2207 | |
| 2208 | # Change one the value of the source and check that it synchronizes the target. |
| 2209 | a.value = 5 |
| 2210 | self.assertEqual(b.value, 5) |
| 2211 | # Change one the value of the target and check that it has no impact on the source |
| 2212 | b.value = 6 |
| 2213 | self.assertEqual(a.value, 5) |
| 2214 | |
| 2215 | def test_tranform(self): |
| 2216 | """Test transform link.""" |
nothing calls this directly
no test coverage detected