示例#1
0
 class TestElement(Element):
     schema = [
         Leaf(obj_type=str),
         {
             'test': TestChild
         },
     ]
示例#2
0
    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})
示例#3
0
 class TestElement(Element):
     schema = Leaf(obj_type=(1, ))
示例#4
0
        class ChildElement(Element):
            schema = Leaf(obj_type=str)

            def parse(self):
                return self.ancestor(TestElement).value
示例#5
0
 class TestLeaf(Element):
     schema = Leaf(obj_type=str)
示例#6
0
 class TestChild(Element):
     schema = Leaf(obj_type=str)
     requires = {
         'self':
         [Value('req', multiple_results=True, predicate=predicate)],
     }
示例#7
0
 class TestElement(Element):
     required = True
     schema = Leaf(obj_type=str)
示例#8
0
 class TestChild(Element):
     schema = Leaf(obj_type=int)
示例#9
0
 class TestChildElement(Element):
     schema = Leaf(obj_type=str)
示例#10
0
 class TestDictValue(Element):
     schema = Leaf(obj_type=str)
示例#11
0
 class TestLeaf2(Element):
     schema = Leaf(obj_type=(str, bool, list))
示例#12
0
 class TestListLeaf(Element):
     schema = Leaf(obj_type=list)
示例#13
0
 class TestDictLeaf(Element):
     schema = Leaf(obj_type=dict)
示例#14
0
 class TestList(Element):
     schema = [Leaf(obj_type=str), [Leaf(obj_type=int)]]