@@ -214,29 +214,31 @@ def custom_handler(signum, frame):
214
214
215
215
signal .signal (signal .SIGINT , custom_handler )
216
216
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 ()
220
221
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
224
225
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
227
228
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 )
232
233
233
- _BackendQT5 .mainloop ()
234
+ _BackendQT5 .mainloop ()
234
235
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
237
238
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 )
240
242
241
243
242
244
@pytest .mark .parametrize (
0 commit comments