@pytest.mark.backend('Qt5Agg')
def test_fig_signals(qt_module):
    fig = plt.figure()
    QtCore = qt_module[0]
    import signal
    event_loop_signal = None

    def fire_signal_and_quit():
        nonlocal event_loop_signal
        event_loop_signal = signal.getsignal(signal.SIGINT)
        QtCore.QCoreApplication.exit()
    QtCore.QTimer.singleShot(0, fire_signal_and_quit)
    original_signal = signal.getsignal(signal.SIGINT)

    def CustomHandler(signum, frame):
        pass
    signal.signal(signal.SIGINT, CustomHandler)
    matplotlib.backends.backend_qt5._BackendQT5.mainloop()
    assert (event_loop_signal == signal.SIG_DFL)
    assert (CustomHandler == signal.getsignal(signal.SIGINT))
    signal.signal(signal.SIGINT, original_signal)
@pytest.mark.backend('Qt5Agg')
def test_fig_signals(qt_module):
    fig = plt.figure()
    QtCore = qt_module[0]
    import signal
    event_loop_signal = None

    def fire_signal_and_quit():
        nonlocal event_loop_signal
        event_loop_signal = signal.getsignal(signal.SIGINT)
        QtCore.QCoreApplication.exit()
    QtCore.QTimer.singleShot(0, fire_signal_and_quit)
    original_signal = signal.getsignal(signal.SIGINT)

    def CustomHandler(signum, frame):
        pass
    signal.signal(signal.SIGINT, CustomHandler)
    matplotlib.backends.backend_qt5._BackendQT5.mainloop()
    assert (event_loop_signal == signal.SIG_DFL)
    assert (CustomHandler == signal.getsignal(signal.SIGINT))
    signal.signal(signal.SIGINT, original_signal)