Show More
@@ -367,29 +367,29 b' class TestHasTraitsNotify(TestCase):' | |||||
367 |
|
367 | |||
368 | class A(HasTraits): |
|
368 | class A(HasTraits): | |
369 | listen_to = ['a'] |
|
369 | listen_to = ['a'] | |
370 |
|
370 | |||
371 | a = Int(0) |
|
371 | a = Int(0) | |
372 | b = 0 |
|
372 | b = 0 | |
373 |
|
373 | |||
374 | def __init__(self, **kwargs): |
|
374 | def __init__(self, **kwargs): | |
375 | super(A, self).__init__(**kwargs) |
|
375 | super(A, self).__init__(**kwargs) | |
376 | self.on_trait_change(self.listener1, ['a']) |
|
376 | self.on_trait_change(self.listener1, ['a']) | |
377 |
|
377 | |||
378 | def listener1(self, name, old, new): |
|
378 | def listener1(self, name, old, new): | |
379 | self.b += 1 |
|
379 | self.b += 1 | |
380 |
|
380 | |||
381 | class B(A): |
|
381 | class B(A): | |
382 |
|
382 | |||
383 | c = 0 |
|
383 | c = 0 | |
384 | d = 0 |
|
384 | d = 0 | |
385 |
|
385 | |||
386 | def __init__(self, **kwargs): |
|
386 | def __init__(self, **kwargs): | |
387 | super(B, self).__init__(**kwargs) |
|
387 | super(B, self).__init__(**kwargs) | |
388 | self.on_trait_change(self.listener2) |
|
388 | self.on_trait_change(self.listener2) | |
389 |
|
389 | |||
390 | def listener2(self, name, old, new): |
|
390 | def listener2(self, name, old, new): | |
391 | self.c += 1 |
|
391 | self.c += 1 | |
392 |
|
392 | |||
393 | def _a_changed(self, name, old, new): |
|
393 | def _a_changed(self, name, old, new): | |
394 | self.d += 1 |
|
394 | self.d += 1 | |
395 |
|
395 | |||
@@ -455,7 +455,7 b' class TestHasTraits(TestCase):' | |||||
455 | def __init__(self, i): |
|
455 | def __init__(self, i): | |
456 | super(A, self).__init__() |
|
456 | super(A, self).__init__() | |
457 | self.i = i |
|
457 | self.i = i | |
458 |
|
458 | |||
459 | a = A(5) |
|
459 | a = A(5) | |
460 | self.assertEqual(a.i, 5) |
|
460 | self.assertEqual(a.i, 5) | |
461 | # should raise TypeError if no positional arg given |
|
461 | # should raise TypeError if no positional arg given | |
@@ -888,7 +888,7 b' class TestList(TraitTestBase):' | |||||
888 | _default_value = [] |
|
888 | _default_value = [] | |
889 | _good_values = [[], [1], list(range(10)), (1,2)] |
|
889 | _good_values = [[], [1], list(range(10)), (1,2)] | |
890 | _bad_values = [10, [1,'a'], 'a'] |
|
890 | _bad_values = [10, [1,'a'], 'a'] | |
891 |
|
891 | |||
892 | def coerce(self, value): |
|
892 | def coerce(self, value): | |
893 | if value is not None: |
|
893 | if value is not None: | |
894 | value = list(value) |
|
894 | value = list(value) | |
@@ -1086,7 +1086,7 b' class TestLink(TestCase):' | |||||
1086 | count = Int() |
|
1086 | count = Int() | |
1087 | a = A(value=9) |
|
1087 | a = A(value=9) | |
1088 | b = B(count=8) |
|
1088 | b = B(count=8) | |
1089 |
|
1089 | |||
1090 | # Register callbacks that count. |
|
1090 | # Register callbacks that count. | |
1091 | callback_count = [] |
|
1091 | callback_count = [] | |
1092 | def a_callback(name, old, new): |
|
1092 | def a_callback(name, old, new): |
@@ -232,7 +232,7 b' class link(object):' | |||||
232 | for obj,attr in self.objects.keys(): |
|
232 | for obj,attr in self.objects.keys(): | |
233 | if obj is not sending_obj or attr != sending_attr: |
|
233 | if obj is not sending_obj or attr != sending_attr: | |
234 | setattr(obj, attr, new) |
|
234 | setattr(obj, attr, new) | |
235 |
|
235 | |||
236 | def unlink(self): |
|
236 | def unlink(self): | |
237 | for key, callback in self.objects.items(): |
|
237 | for key, callback in self.objects.items(): | |
238 | (obj,attr) = key |
|
238 | (obj,attr) = key | |
@@ -1374,7 +1374,7 b' class List(Container):' | |||||
1374 | self.length_error(obj, value) |
|
1374 | self.length_error(obj, value) | |
1375 |
|
1375 | |||
1376 | return super(List, self).validate_elements(obj, value) |
|
1376 | return super(List, self).validate_elements(obj, value) | |
1377 |
|
1377 | |||
1378 | def validate(self, obj, value): |
|
1378 | def validate(self, obj, value): | |
1379 | value = super(List, self).validate(obj, value) |
|
1379 | value = super(List, self).validate(obj, value) | |
1380 | if value is None: |
|
1380 | if value is None: | |
@@ -1383,7 +1383,7 b' class List(Container):' | |||||
1383 | value = self.validate_elements(obj, value) |
|
1383 | value = self.validate_elements(obj, value) | |
1384 |
|
1384 | |||
1385 | return value |
|
1385 | return value | |
1386 |
|
1386 | |||
1387 |
|
1387 | |||
1388 |
|
1388 | |||
1389 | class Set(List): |
|
1389 | class Set(List): |
General Comments 0
You need to be logged in to leave comments.
Login now