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 1111from pluggy import PluginValidationError
1212from pluggy ._hooks import HookCaller
1313from pluggy ._hooks import HookImpl
14+ from pluggy ._tracing import saferepr
1415
1516hookspec = HookspecMarker ("example" )
1617hookimpl = HookimplMarker ("example" )
@@ -448,3 +449,21 @@ def conflict(self) -> None:
448449 "Hook 'conflict' is already registered within namespace "
449450 "<class 'test_hookcaller.test_hook_conflict.<locals>.Api1'>"
450451 )
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