MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / raising_cb_reg

Function raising_cb_reg

lib/matplotlib/tests/test_cbook.py:468–498  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

466
467
468def 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

Callers

nothing calls this directly

Calls 1

connectMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…