def test_dict_type_basic(self): d = Dict('name') with self.assertRaises(ValueError): d({'foo': 'bar'}) d = Dict(Any, 'name') d({'foo': 'bar'}) # doesn't raise
def test_dict_type_basic(self): d = Dict("name") with self.assertRaises(ValueError): d({"foo": "bar"}) d = Dict(Any, "name") d({"foo": "bar"}) # doesn't raise
def test_tuple_type_with_recursive_item_types(self): t = Tuple((Dict(List(Any)), List(Dict(Any)), Unicode), 'name') with self.assertRaises(ValueError): t(({'foo': 'bar'}, [{'foo': 'bar'}], 'foo')) with self.assertRaises(ValueError): t(({'foo': ['bar']}, ['foo'], 'foo')) t(({'foo': ['bar']}, [{'foo': 'bar'}], 'foo')) # doesn't raise
def test_tuple_type_with_recursive_item_types(self): t = Tuple((Dict(List(Any)), List(Dict(Any)), Unicode), "name") with self.assertRaises(ValueError): t(({"foo": "bar"}, [{"foo": "bar"}], "foo")) with self.assertRaises(ValueError): t(({"foo": ["bar"]}, ["foo"], "foo")) t(({"foo": ["bar"]}, [{"foo": "bar"}], "foo")) # doesn't raise
def test_dict_type_with_recursive_item_types(self): d = Dict(Dict({Unicode: List(Int)}), 'name') with self.assertRaises(ValueError): d({'foo': 'bar'}) with self.assertRaises(ValueError): d({'foo': {'bar': 'baz'}}) with self.assertRaises(ValueError): d({'foo': {'bar': ['baz']}}) d({'foo': {'bar': [1]}}) # doesn't raise
def test_dict_type_with_recursive_item_types(self): d = Dict(Dict({Unicode: List(Int)}), "name") with self.assertRaises(ValueError): d({"foo": "bar"}) with self.assertRaises(ValueError): d({"foo": {"bar": "baz"}}) with self.assertRaises(ValueError): d({"foo": {"bar": ["baz"]}}) d({"foo": {"bar": [1]}}) # doesn't raise
def test_dict_type_with_dictionary_item_type(self): d = Dict({Int: Int}, 'name') with self.assertRaises(ValueError): d({'foo': 1}) with self.assertRaises(ValueError): d({1: 'foo'}) d({1: 2}) # doesn't raise
def test_dict_type_with_dictionary_item_type(self): d = Dict({Int: Int}, "name") with self.assertRaises(ValueError): d({"foo": 1}) with self.assertRaises(ValueError): d({1: "foo"}) d({1: 2}) # doesn't raise
def test_list_type_with_recursive_item_types(self): l = List(Dict(List(Tuple((Unicode, Int)))), 'name') with self.assertRaises(ValueError): l(['foo']) with self.assertRaises(ValueError): l([{'foo': 'bar'}]) with self.assertRaises(ValueError): l([{'foo': ['bar']}]) l([{'foo': [('bar', 1)]}]) # doesn't raise
def test_list_type_with_recursive_item_types(self): l = List(Dict(List(Tuple((Unicode, Int)))), "name") with self.assertRaises(ValueError): l(["foo"]) with self.assertRaises(ValueError): l([{"foo": "bar"}]) with self.assertRaises(ValueError): l([{"foo": ["bar"]}]) l([{"foo": [("bar", 1)]}]) # doesn't raise