Show More
@@ -25,10 +25,11 b' import re' | |||
|
25 | 25 | import sys |
|
26 | 26 | from unittest import TestCase |
|
27 | 27 | |
|
28 | import nose.tools as nt | |
|
28 | 29 | from nose import SkipTest |
|
29 | 30 | |
|
30 | 31 | from IPython.utils.traitlets import ( |
|
31 | HasTraits, MetaHasTraits, TraitType, Any, CBytes, | |
|
32 | HasTraits, MetaHasTraits, TraitType, Any, CBytes, Dict, | |
|
32 | 33 | Int, Long, Integer, Float, Complex, Bytes, Unicode, TraitError, |
|
33 | 34 | Undefined, Type, This, Instance, TCPAddress, List, Tuple, |
|
34 | 35 | ObjectName, DottedObjectName, CRegExp |
@@ -906,3 +907,14 b' class TestCRegExp(TraitTestBase):' | |||
|
906 | 907 | _default_value = re.compile(r'') |
|
907 | 908 | _good_values = [r'\d+', re.compile(r'\d+')] |
|
908 | 909 | _bad_values = [r'(', None, ()] |
|
910 | ||
|
911 | class DictTrait(HasTraits): | |
|
912 | value = Dict() | |
|
913 | ||
|
914 | def test_dict_assignment(): | |
|
915 | d = dict() | |
|
916 | c = DictTrait() | |
|
917 | c.value = d | |
|
918 | d['a'] = 5 | |
|
919 | nt.assert_equal(d, c.value) | |
|
920 | nt.assert_true(c.value is d) |
@@ -309,8 +309,8 b' class TraitType(object):' | |||
|
309 | 309 | def __set__(self, obj, value): |
|
310 | 310 | new_value = self._validate(obj, value) |
|
311 | 311 | old_value = self.__get__(obj) |
|
312 | obj._trait_values[self.name] = new_value | |
|
312 | 313 | if old_value != new_value: |
|
313 | obj._trait_values[self.name] = new_value | |
|
314 | 314 | obj._notify_trait(self.name, old_value, new_value) |
|
315 | 315 | |
|
316 | 316 | def _validate(self, obj, value): |
General Comments 0
You need to be logged in to leave comments.
Login now