File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 ParseError ,
1515 PatchError ,
1616 QueryError ,
17+ RoutingError ,
1718 YAMLTripError ,
1819)
1920
@@ -52,6 +53,7 @@ def edit(path: str | Path) -> Editor:
5253 "PatchError" ,
5354 "QueryError" ,
5455 "Route" ,
56+ "RoutingError" ,
5557 "YAMLTripError" ,
5658 "edit" ,
5759 "load" ,
Original file line number Diff line number Diff line change @@ -25,5 +25,9 @@ class KeyMissingError(PatchError):
2525 """Raised by replace() when the key doesn't exist."""
2626
2727
28+ class RoutingError (PatchError ):
29+ """Raised when a key path passes through a non-mapping node."""
30+
31+
2832class NodeTypeError (PatchError , TypeError ):
2933 """Raised when a node is not the expected type for the operation."""
Original file line number Diff line number Diff line change 77 ParseError ,
88 PatchError ,
99 QueryError ,
10+ RoutingError ,
1011 YAMLTripError ,
1112)
1213
@@ -38,3 +39,23 @@ def test_raise_and_catch_base(self):
3839 msg = "key already exists"
3940 with pytest .raises (YAMLTripError , match = msg ):
4041 raise KeyExistsError (msg )
42+
43+
44+ class TestRoutingErrorHierarchy :
45+ def test_routing_error_is_patch_error (self ):
46+ assert issubclass (RoutingError , PatchError )
47+
48+ def test_routing_error_is_not_type_error (self ):
49+ assert not issubclass (RoutingError , TypeError )
50+
51+ def test_routing_error_is_not_node_type_error (self ):
52+ assert not issubclass (RoutingError , NodeTypeError )
53+
54+ def test_raise_and_catch_as_patch_error (self ):
55+ msg = "route through scalar"
56+ with pytest .raises (PatchError ):
57+ raise RoutingError (msg )
58+
59+ def test_message (self ):
60+ err = RoutingError ("Route passes through a non-mapping node at a" )
61+ assert "a" in str (err )
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def test_error_classes(self):
3939 assert issubclass (yamltrip .PatchError , yamltrip .YAMLTripError )
4040 assert issubclass (yamltrip .KeyExistsError , yamltrip .PatchError )
4141 assert issubclass (yamltrip .KeyMissingError , yamltrip .PatchError )
42+ assert issubclass (yamltrip .RoutingError , yamltrip .PatchError )
4243
4344 def test_core_types (self ):
4445 assert yamltrip .Location is not None
You can’t perform that action at this time.
0 commit comments