当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.ErrorTree方法代码示例

本文整理汇总了Python中jsonschema.exceptions.ErrorTree方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.ErrorTree方法的具体用法?Python exceptions.ErrorTree怎么用?Python exceptions.ErrorTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonschema.exceptions的用法示例。


在下文中一共展示了exceptions.ErrorTree方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_it_knows_how_many_total_errors_it_contains

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_it_knows_how_many_total_errors_it_contains(self):
        errors = [mock.MagicMock() for _ in range(8)]
        tree = exceptions.ErrorTree(errors)
        self.assertEqual(tree.total_errors, 8) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_exceptions.py

示例2: test_it_contains_an_item_if_the_item_had_an_error

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_it_contains_an_item_if_the_item_had_an_error(self):
        errors = [exceptions.ValidationError("a message", path=["bar"])]
        tree = exceptions.ErrorTree(errors)
        self.assertIn("bar", tree) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_exceptions.py

示例3: test_it_does_not_contain_an_item_if_the_item_had_no_error

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_it_does_not_contain_an_item_if_the_item_had_no_error(self):
        errors = [exceptions.ValidationError("a message", path=["bar"])]
        tree = exceptions.ErrorTree(errors)
        self.assertNotIn("foo", tree) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_exceptions.py

示例4: test_validators_that_failed_appear_in_errors_dict

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_validators_that_failed_appear_in_errors_dict(self):
        error = exceptions.ValidationError("a message", validator="foo")
        tree = exceptions.ErrorTree([error])
        self.assertEqual(tree.errors, {"foo": error}) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:6,代码来源:test_exceptions.py

示例5: test_it_creates_a_child_tree_for_each_nested_path

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_it_creates_a_child_tree_for_each_nested_path(self):
        errors = [
            exceptions.ValidationError("a bar message", path=["bar"]),
            exceptions.ValidationError("a bar -> 0 message", path=["bar", 0]),
        ]
        tree = exceptions.ErrorTree(errors)
        self.assertIn(0, tree["bar"])
        self.assertNotIn(1, tree["bar"]) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:10,代码来源:test_exceptions.py

示例6: test_regression_multiple_errors_with_instance

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_regression_multiple_errors_with_instance(self):
        e1, e2 = (
            exceptions.ValidationError(
                "1",
                validator="foo",
                path=["bar", "bar2"],
                instance="i1"),
            exceptions.ValidationError(
                "2",
                validator="quux",
                path=["foobar", 2],
                instance="i2"),
        )
        # Will raise an exception if the bug is still there.
        exceptions.ErrorTree([e1, e2]) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:17,代码来源:test_exceptions.py

示例7: test_it_does_not_contain_subtrees_that_are_not_in_the_instance

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_it_does_not_contain_subtrees_that_are_not_in_the_instance(self):
        error = exceptions.ValidationError("123", validator="foo", instance=[])
        tree = exceptions.ErrorTree([error])

        with self.assertRaises(IndexError):
            tree[0] 
开发者ID:remg427,项目名称:misp42splunk,代码行数:8,代码来源:test_exceptions.py

示例8: test_if_its_in_the_tree_anyhow_it_does_not_raise_an_error

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_if_its_in_the_tree_anyhow_it_does_not_raise_an_error(self):
        """
        If a validator is dumb (like :validator:`required` in draft 3) and
        refers to a path that isn't in the instance, the tree still properly
        returns a subtree for that path.

        """

        error = exceptions.ValidationError(
            "a message", validator="foo", instance={}, path=["foo"],
        )
        tree = exceptions.ErrorTree([error])
        self.assertIsInstance(tree["foo"], exceptions.ErrorTree) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:15,代码来源:test_exceptions.py

示例9: test_children_have_their_errors_dicts_built

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_children_have_their_errors_dicts_built(self):
        e1, e2 = (
            exceptions.ValidationError("1", validator="foo", path=["bar", 0]),
            exceptions.ValidationError("2", validator="quux", path=["bar", 0]),
        )
        tree = exceptions.ErrorTree([e1, e2])
        self.assertEqual(tree["bar"][0].errors, {"foo": e1, "quux": e2}) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:9,代码来源:test_exceptions.py

示例10: test_validators_that_failed_appear_in_errors_dict

# 需要导入模块: from jsonschema import exceptions [as 别名]
# 或者: from jsonschema.exceptions import ErrorTree [as 别名]
def test_validators_that_failed_appear_in_errors_dict(self):
        error = exceptions.ValidationError("a message", validator="foo")
        tree = exceptions.ErrorTree([error])
        self.assertEqual(tree.errors, {"foo" : error}) 
开发者ID:getavalon,项目名称:core,代码行数:6,代码来源:test_exceptions.py


注:本文中的jsonschema.exceptions.ErrorTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。