def test_Tuple(self): with self.assertRaises(TypeError): prop = Tuple() with self.assertRaises(TypeError): prop = Tuple(Int) prop = Tuple(Int, String, List(Int)) self.assertTrue(prop.is_valid(None)) self.assertFalse(prop.is_valid(False)) self.assertFalse(prop.is_valid(True)) self.assertFalse(prop.is_valid(0)) self.assertFalse(prop.is_valid(1)) self.assertFalse(prop.is_valid(0.0)) self.assertFalse(prop.is_valid(1.0)) self.assertFalse(prop.is_valid(1.0 + 1.0j)) self.assertFalse(prop.is_valid("")) self.assertFalse(prop.is_valid(())) self.assertFalse(prop.is_valid([])) self.assertFalse(prop.is_valid({})) self.assertFalse(prop.is_valid(Foo())) self.assertTrue(prop.is_valid((1, "", [1, 2, 3]))) self.assertFalse(prop.is_valid((1.0, "", [1, 2, 3]))) self.assertFalse(prop.is_valid((1, True, [1, 2, 3]))) self.assertFalse(prop.is_valid((1, "", (1, 2, 3)))) self.assertFalse(prop.is_valid((1, "", [1, 2, "xyz"])))
class InstallersModel(VBoxModelForm): period = Tuple(Date, Date, default=(start, end)) installer = Enum("All", *sorted(installers.event.unique())) resolution = Enum("daily", "monthly", "yearly", default="monthly") platform = Enum("All", *sorted(installers.platform.unique())) arch = Enum("All", *sorted(installers.arch.unique())) #start = Date(start) #end = Date(end) input_specs = [ { "widget": DateRangeSlider, "name": "period", "title": "Period:", "value": period.default, "bounds": period.default, "range": (dict(days=1), None), }, { "widget": Select, "name": "installer", "title": "Installer:", "value": installer.default, "options": installer.allowed_values, }, { "widget": Select, "name": "resolution", "title": "Resolution:", "value": resolution.default, "options": resolution.allowed_values, }, { "widget": Select, "name": "platform", "title": "Platform:", "value": platform.default, "options": platform.allowed_values, }, { "widget": Select, "name": "arch", "title": "Architecture:", "value": arch.default, "options": arch.allowed_values, #}, { # "widget": DatePicker, # "name": "start", # "title": "Start:", # "value": start.default, # "min_date": start.default, #}, { # "widget": DatePicker, # "name": "end", # "title": "End:", # "value": end.default, # "max_date": end.default, #}] } ]
class Foo(PlotObject): """ This is a Foo model. """ index = Either(Auto, Enum('abc', 'def', 'xzy'), help="doc for index") value = Tuple(Float, Float, help="doc for value")
class V(self.pObjectClass): u1 = Instance(U) u2 = List(Instance(U)) u3 = Tuple(Int, Instance(U)) u4 = Dict(String, Instance(U)) u5 = Dict(String, List(Instance(U)))
class V(PlotObject): u1 = Instance(U) u2 = List(Instance(U)) u3 = Tuple(Int, Instance(U)) u4 = Dict(String, Instance(U)) u5 = Dict(String, List(Instance(U)))