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

Method test_unlink_link

tests/test_traitlets.py:2264–2285  ·  view source on GitHub ↗

Verify two linked traitlets can be unlinked and relinked.

(self)

Source from the content-addressed store, hash-verified

2262 self.assertEqual(a.value, 5)
2263
2264 def test_unlink_link(self):
2265 """Verify two linked traitlets can be unlinked and relinked."""
2266
2267 # Create two simple classes with Int traitlets.
2268 class A(HasTraits):
2269 value = Int()
2270
2271 a = A(value=9)
2272 b = A(value=8)
2273
2274 # Connect the two classes.
2275 c = directional_link((a, "value"), (b, "value"))
2276 a.value = 4
2277 c.unlink()
2278
2279 # Change one of the values to make sure they don't stay in sync.
2280 a.value = 5
2281 self.assertNotEqual(a.value, b.value)
2282 c.link()
2283 self.assertEqual(a.value, b.value)
2284 a.value += 1
2285 self.assertEqual(a.value, b.value)
2286
2287
2288class Pickleable(HasTraits):

Callers

nothing calls this directly

Calls 4

directional_linkClass · 0.90
AClass · 0.70
unlinkMethod · 0.45
linkMethod · 0.45

Tested by

no test coverage detected