@@ -214,29 +214,31 @@ def custom_handler(signum, frame):
214214
215215 signal .signal (signal .SIGINT , custom_handler )
216216
217- # mainloop() sets SIGINT, starts Qt event loop (which triggers timer and
218- # exits) and then mainloop() resets SIGINT
219- matplotlib .backends .backend_qt ._BackendQT .mainloop ()
217+ try :
218+ # mainloop() sets SIGINT, starts Qt event loop (which triggers timer
219+ # and exits) and then mainloop() resets SIGINT
220+ matplotlib .backends .backend_qt ._BackendQT .mainloop ()
220221
221- # Assert: signal handler during loop execution is changed
222- # (can't test equality with func)
223- assert event_loop_handler != custom_handler
222+ # Assert: signal handler during loop execution is changed
223+ # (can't test equality with func)
224+ assert event_loop_handler != custom_handler
224225
225- # Assert: current signal handler is the same as the one we set before
226- assert signal .getsignal (signal .SIGINT ) == custom_handler
226+ # Assert: current signal handler is the same as the one we set before
227+ assert signal .getsignal (signal .SIGINT ) == custom_handler
227228
228- # Repeat again to test that SIG_DFL and SIG_IGN will not be overridden
229- for custom_handler in (signal .SIG_DFL , signal .SIG_IGN ):
230- qt_core .QTimer .singleShot (0 , fire_signal_and_quit )
231- signal .signal (signal .SIGINT , custom_handler )
229+ # Repeat again to test that SIG_DFL and SIG_IGN will not be overridden
230+ for custom_handler in (signal .SIG_DFL , signal .SIG_IGN ):
231+ qt_core .QTimer .singleShot (0 , fire_signal_and_quit )
232+ signal .signal (signal .SIGINT , custom_handler )
232233
233- _BackendQT5 .mainloop ()
234+ _BackendQT5 .mainloop ()
234235
235- assert event_loop_handler == custom_handler
236- assert signal .getsignal (signal .SIGINT ) == custom_handler
236+ assert event_loop_handler == custom_handler
237+ assert signal .getsignal (signal .SIGINT ) == custom_handler
237238
238- # Reset SIGINT handler to what it was before the test
239- signal .signal (signal .SIGINT , original_handler )
239+ finally :
240+ # Reset SIGINT handler to what it was before the test
241+ signal .signal (signal .SIGINT , original_handler )
240242
241243
242244@pytest .mark .parametrize (
0 commit comments