File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11
11
from pluggy import PluginValidationError
12
12
from pluggy ._hooks import HookCaller
13
13
from pluggy ._hooks import HookImpl
14
+ from pluggy ._tracing import saferepr
14
15
15
16
hookspec = HookspecMarker ("example" )
16
17
hookimpl = HookimplMarker ("example" )
@@ -448,3 +449,21 @@ def conflict(self) -> None:
448
449
"Hook 'conflict' is already registered within namespace "
449
450
"<class 'test_hookcaller.test_hook_conflict.<locals>.Api1'>"
450
451
)
452
+
453
+ def test_hookcaller_repr_with_saferepr_failure (hc : HookCaller , addmeth : AddMeth ) -> None :
454
+ @addmeth ()
455
+ def he_method1 () -> None :
456
+ pass
457
+
458
+ @addmeth ()
459
+ def he_method2 () -> None :
460
+ # Intentional error to make the repr fail
461
+ raise ValueError ("Intentional error in he_method2" )
462
+
463
+ @addmeth ()
464
+ def he_method3 () -> None :
465
+ pass
466
+
467
+ # Verify that HookCaller.repr with saferepr still works despite the error
468
+ expected_repr = f"<HookCaller { saferepr (hc .name )} >"
469
+ assert repr (hc ) == expected_repr
You can’t perform that action at this time.
0 commit comments