Exemplo n.º 1
0
 def test_missing_element(self):
     # b is missing
     with self.assertRaises(DataGenError):
         parse_element({
             "object": "a",
             **linenum
         }, "object", {"b": str}, {}, ParseContext())
Exemplo n.º 2
0
 def test_defaulted_element(self):
     # q should be defaulted
     result = parse_element({
         "object": "a",
         **linenum
     }, "object", {}, {"q": str}, ParseContext())
     assert result.q is None
 def test_parse_element(self):
     result = parse_element(
         {"object": "a", "b": "c", **linenum},
         "object",
         {"b": str},
         {},
         ParseContext(),
     )
     assert result.b == "c"
 def test_optional_element(self):
     # b is missing
     result = parse_element(
         {"object": "a", "q": "z", **linenum},
         "object",
         {},
         {"q": str},
         ParseContext(),
     )
     assert result.q == "z"
 def test_unknown_element(self):
     # b is missing
     with pytest.raises(DataGenError):
         parse_element(
             {"object": "a", "q": "z", **linenum}, "object", {}, {}, ParseContext()
         )