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

Method test_unlink_link

tests/test_traitlets.py:2074–2095  ·  view source on GitHub ↗

Verify two linked traitlets can be unlinked and relinked.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 4

linkClass · 0.90
AClass · 0.70
unlinkMethod · 0.45
linkMethod · 0.45

Tested by

no test coverage detected