From fce9b7b79c724e9f6a6a9b86b291f106f7b480e3 2014-11-19 04:07:13 From: Sylvain Corlay Date: 2014-11-19 04:07:13 Subject: [PATCH] Test for Union Traitlet --- diff --git a/IPython/utils/tests/test_traitlets.py b/IPython/utils/tests/test_traitlets.py index dff8974..f1a0679 100644 --- a/IPython/utils/tests/test_traitlets.py +++ b/IPython/utils/tests/test_traitlets.py @@ -18,7 +18,7 @@ from nose import SkipTest from IPython.utils.traitlets import ( HasTraits, MetaHasTraits, TraitType, Any, CBytes, Dict, Int, Long, Integer, Float, Complex, Bytes, Unicode, TraitError, - Undefined, Type, This, Instance, TCPAddress, List, Tuple, + Union, Undefined, Type, This, Instance, TCPAddress, List, Tuple, ObjectName, DottedObjectName, CRegExp, link, directional_link, EventfulList, EventfulDict, ForwardDeclaredType, ForwardDeclaredInstance, ) @@ -760,6 +760,16 @@ class AnyTraitTest(TraitTestBase): _good_values = [10.0, 'ten', u'ten', [10], {'ten': 10},(10,), None, 1j] _bad_values = [] +class UnionTrait(HasTraits): + + value = Union([Type(), Unicode()]) + +class UnionTraitTest(TraitTestBase): + + obj = UnionTrait() + _default_value = None + _good_values = [int, float, 'ten'] + _bad_values = [[], (0,), 1j] class IntTrait(HasTraits):