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