def test_connect_same_trait_target_undefined(self, A=_B, B=_A): """Verify two traitlets of the same type can be linked together using link.""" a = A(value=9) b = B() # b.value is Undefined # Conenct the two classes. c = link((a, 'value'), (b, 'value')) assert b.value == 9 # Change one of the values to make sure they stay in sync. a.value = 5 assert a.value == b.value b.value = 6 assert a.value == b.value del b.value # Reset trait (to Undefined in this case) if has_traitlets(a): # linking sets b.value to 0 if it has traitlets assert a.value == 0 else: assert a.value is t.Undefined
def test_connect_same_trait_source_undefined(self, A=_A, B=_B): """Verify two traitlets of the same type can be linked together using link.""" a = A() # a.value is Undefined b = B(value=8) # Conenct the two classes. c = link((a, 'value'), (b, 'value')) # Linking doesn't change b.value because a.value is undefined assert b.value == 8 # Change one of the values to make sure they stay in sync. a.value = 5 assert a.value == b.value b.value = 6 assert a.value == b.value del a.value # Reset trait (to Undefined in this case) if has_traitlets(b): # linking sets b.value to 0 if it has traitlets assert b.value == 0 else: assert b.value is t.Undefined