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

Function test_callbackregistry_blocking

lib/matplotlib/tests/test_cbook.py:522–552  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

520
521
522def test_callbackregistry_blocking():
523 # Needs an exception handler for interactive testing environments
524 # that would only print this out instead of raising the exception
525 def raise_handler(excp):
526 raise excp
527 cb = cbook.CallbackRegistry(exception_handler=raise_handler)
528 def test_func1():
529 raise ValueError("1 should be blocked")
530 def test_func2():
531 raise ValueError("2 should be blocked")
532 cb.connect("test1", test_func1)
533 cb.connect("test2", test_func2)
534
535 # block all of the callbacks to make sure they aren't processed
536 with cb.blocked():
537 cb.process("test1")
538 cb.process("test2")
539
540 # block individual callbacks to make sure the other is still processed
541 with cb.blocked(signal="test1"):
542 # Blocked
543 cb.process("test1")
544 # Should raise
545 with pytest.raises(ValueError, match="2 should be blocked"):
546 cb.process("test2")
547
548 # Make sure the original callback functions are there after blocking
549 with pytest.raises(ValueError, match="1 should be blocked"):
550 cb.process("test1")
551 with pytest.raises(ValueError, match="2 should be blocked"):
552 cb.process("test2")
553
554
555@pytest.mark.parametrize('line, result', [

Callers

nothing calls this directly

Calls 3

connectMethod · 0.95
blockedMethod · 0.95
processMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…