Test transform link.
(self)
| 2213 | self.assertEqual(a.value, 5) |
| 2214 | |
| 2215 | def test_tranform(self): |
| 2216 | """Test transform link.""" |
| 2217 | |
| 2218 | # Create two simple classes with Int traitlets. |
| 2219 | class A(HasTraits): |
| 2220 | value = Int() |
| 2221 | |
| 2222 | a = A(value=9) |
| 2223 | b = A(value=8) |
| 2224 | |
| 2225 | # Connect the two classes. |
| 2226 | c = directional_link((a, "value"), (b, "value"), lambda x: 2 * x) |
| 2227 | |
| 2228 | # Make sure the values are correct at the point of linking. |
| 2229 | self.assertEqual(b.value, 2 * a.value) |
| 2230 | |
| 2231 | # Change one the value of the source and check that it modifies the target. |
| 2232 | a.value = 5 |
| 2233 | self.assertEqual(b.value, 10) |
| 2234 | # Change one the value of the target and check that it has no impact on the source |
| 2235 | b.value = 6 |
| 2236 | self.assertEqual(a.value, 5) |
| 2237 | |
| 2238 | def test_link_different(self): |
| 2239 | """Verify two traitlets of different types can be linked together using link.""" |
nothing calls this directly
no test coverage detected