File tree Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Expand file tree Collapse file tree 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,10 @@ def __delitem__(self, uri):
28
28
def __iter__ (self ):
29
29
return iter (self .store )
30
30
31
- def __len__ (self ):
31
+ def __len__ (self ): # pragma: no cover -- untested, but to be removed
32
32
return len (self .store )
33
33
34
- def __repr__ (self ):
34
+ def __repr__ (self ): # pragma: no cover -- untested, but to be removed
35
35
return repr (self .store )
36
36
37
37
Original file line number Diff line number Diff line change @@ -209,14 +209,14 @@ class _RefResolutionError(Exception):
209
209
210
210
def __eq__ (self , other ):
211
211
if self .__class__ is not other .__class__ :
212
- return NotImplemented
212
+ return NotImplemented # pragma: no cover -- uncovered but deprecated # noqa: E501
213
213
return self ._cause == other ._cause
214
214
215
215
def __str__ (self ):
216
216
return str (self ._cause )
217
217
218
218
219
- class _WrappedReferencingError (_RefResolutionError , _Unresolvable ):
219
+ class _WrappedReferencingError (_RefResolutionError , _Unresolvable ): # pragma: no cover -- partially uncovered but to be removed # noqa: E501
220
220
def __init__ (self , cause : _Unresolvable ):
221
221
object .__setattr__ (self , "_wrapped" , cause )
222
222
Original file line number Diff line number Diff line change @@ -396,6 +396,22 @@ def test_if_its_in_the_tree_anyhow_it_does_not_raise_an_error(self):
396
396
tree = exceptions .ErrorTree ([error ])
397
397
self .assertIsInstance (tree ["foo" ], exceptions .ErrorTree )
398
398
399
+ def test_iter (self ):
400
+ e1 , e2 = (
401
+ exceptions .ValidationError (
402
+ "1" ,
403
+ validator = "foo" ,
404
+ path = ["bar" , "bar2" ],
405
+ instance = "i1" ),
406
+ exceptions .ValidationError (
407
+ "2" ,
408
+ validator = "quux" ,
409
+ path = ["foobar" , 2 ],
410
+ instance = "i2" ),
411
+ )
412
+ tree = exceptions .ErrorTree ([e1 , e2 ])
413
+ self .assertEqual (set (tree ), {"bar" , "foobar" })
414
+
399
415
def test_repr_single (self ):
400
416
error = exceptions .ValidationError (
401
417
"1" ,
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ def test_it_catches_registered_errors(self):
54
54
55
55
self .assertIs (cm .exception .cause , BOOM )
56
56
self .assertIs (cm .exception .__cause__ , BOOM )
57
+ self .assertEqual (str (cm .exception ), "12 is not a 'boom'" )
57
58
58
59
# Unregistered errors should not be caught
59
60
with self .assertRaises (type (BANG )):
You can’t perform that action at this time.
0 commit comments