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

Method test_connect_same

tests/test_traitlets.py:2192–2213  ·  view source on GitHub ↗

Verify two traitlets of the same type can be linked together using directional_link.

(self)

Source from the content-addressed store, hash-verified

2190
2191class 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."""

Callers

nothing calls this directly

Calls 2

directional_linkClass · 0.90
AClass · 0.70

Tested by

no test coverage detected