(func)
| 466 | |
| 467 | |
| 468 | def raising_cb_reg(func): |
| 469 | class TestException(Exception): |
| 470 | pass |
| 471 | |
| 472 | def raise_runtime_error(): |
| 473 | raise RuntimeError |
| 474 | |
| 475 | def raise_value_error(): |
| 476 | raise ValueError |
| 477 | |
| 478 | def transformer(excp): |
| 479 | if isinstance(excp, RuntimeError): |
| 480 | raise TestException |
| 481 | raise excp |
| 482 | |
| 483 | # old default |
| 484 | cb_old = cbook.CallbackRegistry(exception_handler=None) |
| 485 | cb_old.connect('foo', raise_runtime_error) |
| 486 | |
| 487 | # filter |
| 488 | cb_filt = cbook.CallbackRegistry(exception_handler=transformer) |
| 489 | cb_filt.connect('foo', raise_runtime_error) |
| 490 | |
| 491 | # filter |
| 492 | cb_filt_pass = cbook.CallbackRegistry(exception_handler=transformer) |
| 493 | cb_filt_pass.connect('foo', raise_value_error) |
| 494 | |
| 495 | return pytest.mark.parametrize('cb, excp', |
| 496 | [[cb_old, RuntimeError], |
| 497 | [cb_filt, TestException], |
| 498 | [cb_filt_pass, ValueError]])(func) |
| 499 | |
| 500 | |
| 501 | @raising_cb_reg |
nothing calls this directly
no test coverage detected
searching dependent graphs…