|
8 | 8 | from jsonschema.compat import PY3 |
9 | 9 | from jsonschema.tests.compat import mock, unittest |
10 | 10 | from jsonschema.validators import ( |
11 | | - RefResolutionError, UnknownType, ErrorTree, Draft3Validator, |
| 11 | + RefResolutionError, UnknownType, Draft3Validator, |
12 | 12 | Draft4Validator, RefResolver, create, extend, validator_for, validate, |
13 | 13 | ) |
14 | 14 |
|
@@ -518,69 +518,6 @@ def test_additionalItems_with_items(self): |
518 | 518 | self.assertEqual(e2.validator, "minimum") |
519 | 519 |
|
520 | 520 |
|
521 | | -class TestErrorTree(unittest.TestCase): |
522 | | - def setUp(self): |
523 | | - self.validator = Draft3Validator({}) |
524 | | - |
525 | | - def test_it_knows_how_many_total_errors_it_contains(self): |
526 | | - errors = [mock.MagicMock() for _ in range(8)] |
527 | | - tree = ErrorTree(errors) |
528 | | - self.assertEqual(tree.total_errors, 8) |
529 | | - |
530 | | - def test_it_contains_an_item_if_the_item_had_an_error(self): |
531 | | - errors = [ValidationError("a message", path=["bar"])] |
532 | | - tree = ErrorTree(errors) |
533 | | - self.assertIn("bar", tree) |
534 | | - |
535 | | - def test_it_does_not_contain_an_item_if_the_item_had_no_error(self): |
536 | | - errors = [ValidationError("a message", path=["bar"])] |
537 | | - tree = ErrorTree(errors) |
538 | | - self.assertNotIn("foo", tree) |
539 | | - |
540 | | - def test_validators_that_failed_appear_in_errors_dict(self): |
541 | | - error = ValidationError("a message", validator="foo") |
542 | | - tree = ErrorTree([error]) |
543 | | - self.assertEqual(tree.errors, {"foo" : error}) |
544 | | - |
545 | | - def test_it_creates_a_child_tree_for_each_nested_path(self): |
546 | | - errors = [ |
547 | | - ValidationError("a bar message", path=["bar"]), |
548 | | - ValidationError("a bar -> 0 message", path=["bar", 0]), |
549 | | - ] |
550 | | - tree = ErrorTree(errors) |
551 | | - self.assertIn(0, tree["bar"]) |
552 | | - self.assertNotIn(1, tree["bar"]) |
553 | | - |
554 | | - def test_children_have_their_errors_dicts_built(self): |
555 | | - e1, e2 = ( |
556 | | - ValidationError("message 1", validator="foo", path=["bar", 0]), |
557 | | - ValidationError("message 2", validator="quux", path=["bar", 0]), |
558 | | - ) |
559 | | - tree = ErrorTree([e1, e2]) |
560 | | - self.assertEqual(tree["bar"][0].errors, {"foo" : e1, "quux" : e2}) |
561 | | - |
562 | | - def test_it_does_not_contain_subtrees_that_are_not_in_the_instance(self): |
563 | | - error = ValidationError("a message", validator="foo", instance=[]) |
564 | | - tree = ErrorTree([error]) |
565 | | - |
566 | | - with self.assertRaises(IndexError): |
567 | | - tree[0] |
568 | | - |
569 | | - def test_if_its_in_the_tree_anyhow_it_does_not_raise_an_error(self): |
570 | | - """ |
571 | | - If a validator is dumb (like :validator:`required` in draft 3) and |
572 | | - refers to a path that isn't in the instance, the tree still properly |
573 | | - returns a subtree for that path. |
574 | | -
|
575 | | - """ |
576 | | - |
577 | | - error = ValidationError( |
578 | | - "a message", validator="foo", instance={}, path=["foo"], |
579 | | - ) |
580 | | - tree = ErrorTree([error]) |
581 | | - self.assertIsInstance(tree["foo"], ErrorTree) |
582 | | - |
583 | | - |
584 | 521 | class ValidatorTestMixin(object): |
585 | 522 | def setUp(self): |
586 | 523 | self.instance = mock.Mock() |
|
0 commit comments