##// END OF EJS Templates
test nested `t.hold_trait_notifications`
Min RK -
Show More
@@ -1331,6 +1331,34 b' def test_pickle_hastraits():'
1331 nt.assert_equal(c2.j, c.j)
1331 nt.assert_equal(c2.j, c.j)
1332
1332
1333
1333
1334 def test_hold_trait_notifications():
1335 changes = []
1336 class Test(HasTraits):
1337 a = Integer(0)
1338 def _a_changed(self, name, old, new):
1339 changes.append((old, new))
1340
1341 t = Test()
1342 with t.hold_trait_notifications():
1343 with t.hold_trait_notifications():
1344 t.a = 1
1345 nt.assert_equal(t.a, 1)
1346 nt.assert_equal(changes, [])
1347 t.a = 2
1348 nt.assert_equal(t.a, 2)
1349 with t.hold_trait_notifications():
1350 t.a = 3
1351 nt.assert_equal(t.a, 3)
1352 nt.assert_equal(changes, [])
1353 t.a = 4
1354 nt.assert_equal(t.a, 4)
1355 nt.assert_equal(changes, [])
1356 t.a = 4
1357 nt.assert_equal(t.a, 4)
1358 nt.assert_equal(changes, [])
1359 nt.assert_equal(changes, [(0,1), (1,2), (2,3), (3,4)])
1360
1361
1334 class OrderTraits(HasTraits):
1362 class OrderTraits(HasTraits):
1335 notified = Dict()
1363 notified = Dict()
1336
1364
General Comments 0
You need to be logged in to leave comments. Login now