class TestElement(Element): schema = [ Leaf(obj_type=str), { 'test': TestChild }, ]
def test_invalid_dict_schema(self): def assertion(schema): test_element = type('TestElement', (Element, ), {'schema': schema}) self._assert_validate_schema_failure(test_element) class TestLeaf(Element): schema = Leaf(obj_type=str) assertion({1: TestLeaf}) assertion({'key': Leaf(obj_type=str)}) assertion({'key': None}) assertion({'key': 'str'}) assertion({'key': Element})
class TestElement(Element): schema = Leaf(obj_type=(1, ))
class ChildElement(Element): schema = Leaf(obj_type=str) def parse(self): return self.ancestor(TestElement).value
class TestLeaf(Element): schema = Leaf(obj_type=str)
class TestChild(Element): schema = Leaf(obj_type=str) requires = { 'self': [Value('req', multiple_results=True, predicate=predicate)], }
class TestElement(Element): required = True schema = Leaf(obj_type=str)
class TestChild(Element): schema = Leaf(obj_type=int)
class TestChildElement(Element): schema = Leaf(obj_type=str)
class TestDictValue(Element): schema = Leaf(obj_type=str)
class TestLeaf2(Element): schema = Leaf(obj_type=(str, bool, list))
class TestListLeaf(Element): schema = Leaf(obj_type=list)
class TestDictLeaf(Element): schema = Leaf(obj_type=dict)
class TestList(Element): schema = [Leaf(obj_type=str), [Leaf(obj_type=int)]]