##// END OF EJS Templates
Merge pull request #5502 from Zaharid/iniinstance...
Thomas Kluyver -
r16537:c890558a merge
parent child Browse files
Show More
@@ -881,6 +881,25 b' class TestList(TraitTestBase):'
881 value = list(value)
881 value = list(value)
882 return value
882 return value
883
883
884 class Foo(object):
885 pass
886
887 class InstanceListTrait(HasTraits):
888
889 value = List(Instance(__name__+'.Foo'))
890
891 class TestInstanceList(TraitTestBase):
892
893 obj = InstanceListTrait()
894
895 def test_klass(self):
896 """Test that the instance klass is properly assigned."""
897 self.assertIs(self.obj.traits()['value']._trait.klass, Foo)
898
899 _default_value = []
900 _good_values = [[Foo(), Foo(), None], None]
901 _bad_values = [['1', 2,], '1', [Foo]]
902
884 class LenListTrait(HasTraits):
903 class LenListTrait(HasTraits):
885
904
886 value = List(Int, [0], minlen=1, maxlen=2)
905 value = List(Int, [0], minlen=1, maxlen=2)
@@ -1105,4 +1124,4 b' def test_pickle_hastraits():'
1105 c2 = pickle.loads(p)
1124 c2 = pickle.loads(p)
1106 nt.assert_equal(c2.i, c.i)
1125 nt.assert_equal(c2.i, c.i)
1107 nt.assert_equal(c2.j, c.j)
1126 nt.assert_equal(c2.j, c.j)
1108 No newline at end of file
1127
@@ -1297,6 +1297,11 b' class Container(Instance):'
1297 validated.append(v)
1297 validated.append(v)
1298 return self.klass(validated)
1298 return self.klass(validated)
1299
1299
1300 def instance_init(self, obj):
1301 if isinstance(self._trait, Instance):
1302 self._trait._resolve_classes()
1303 super(Container, self).instance_init(obj)
1304
1300
1305
1301 class List(Container):
1306 class List(Container):
1302 """An instance of a Python list."""
1307 """An instance of a Python list."""
General Comments 0
You need to be logged in to leave comments. Login now