Show More
@@ -972,6 +972,19 b' class TestList(TraitTestBase):' | |||||
972 | class Foo(object): |
|
972 | class Foo(object): | |
973 | pass |
|
973 | pass | |
974 |
|
974 | |||
|
975 | class NoneInstanceListTrait(HasTraits): | |||
|
976 | ||||
|
977 | value = List(Instance(Foo, allow_none=False)) | |||
|
978 | ||||
|
979 | class TestNoneInstanceList(TraitTestBase): | |||
|
980 | ||||
|
981 | obj = NoneInstanceListTrait() | |||
|
982 | ||||
|
983 | _default_value = [] | |||
|
984 | _good_values = [[Foo(), Foo()], []] | |||
|
985 | _bad_values = [[None], [Foo(), None]] | |||
|
986 | ||||
|
987 | ||||
975 | class InstanceListTrait(HasTraits): |
|
988 | class InstanceListTrait(HasTraits): | |
976 |
|
989 | |||
977 | value = List(Instance(__name__+'.Foo')) |
|
990 | value = List(Instance(__name__+'.Foo')) |
@@ -1461,8 +1461,8 b' class Container(Instance):' | |||||
1461 | def instance_init(self, obj): |
|
1461 | def instance_init(self, obj): | |
1462 | if isinstance(self._trait, TraitType): |
|
1462 | if isinstance(self._trait, TraitType): | |
1463 | self._trait.this_class = self.this_class |
|
1463 | self._trait.this_class = self.this_class | |
1464 |
if hasattr(self._trait, ' |
|
1464 | if hasattr(self._trait, '_resolve_classes'): | |
1465 |
self._trait. |
|
1465 | self._trait._resolve_classes() | |
1466 | super(Container, self).instance_init(obj) |
|
1466 | super(Container, self).instance_init(obj) | |
1467 |
|
1467 | |||
1468 |
|
1468 | |||
@@ -1631,6 +1631,14 b' class Tuple(Container):' | |||||
1631 | validated.append(v) |
|
1631 | validated.append(v) | |
1632 | return tuple(validated) |
|
1632 | return tuple(validated) | |
1633 |
|
1633 | |||
|
1634 | def instance_init(self, obj): | |||
|
1635 | for trait in self._traits: | |||
|
1636 | if isinstance(trait, TraitType): | |||
|
1637 | trait.this_class = self.this_class | |||
|
1638 | if hasattr(trait, '_resolve_classes'): | |||
|
1639 | trait._resolve_classes() | |||
|
1640 | super(Container, self).instance_init(obj) | |||
|
1641 | ||||
1634 |
|
1642 | |||
1635 | class Dict(Instance): |
|
1643 | class Dict(Instance): | |
1636 | """An instance of a Python dict.""" |
|
1644 | """An instance of a Python dict.""" |
General Comments 0
You need to be logged in to leave comments.
Login now