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

Method test_connect_same

tests/test_traitlets.py:2027–2047  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

2025
2026class 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."""

Callers

nothing calls this directly

Calls 2

linkClass · 0.90
AClass · 0.70

Tested by

no test coverage detected