@@ -481,24 +481,27 @@ def test_webagg():
481
481
inspect .getsource (_test_interactive_impl )
482
482
+ "\n _test_interactive_impl()" , "{}" ],
483
483
env = {** os .environ , "MPLBACKEND" : "webagg" , "SOURCE_DATE_EPOCH" : "0" })
484
- url = "http://{}:{}" .format (
485
- mpl .rcParams ["webagg.address" ], mpl .rcParams ["webagg.port" ])
484
+ url = f'http://{ mpl .rcParams ["webagg.address" ]} :{ mpl .rcParams ["webagg.port" ]} '
486
485
timeout = time .perf_counter () + _test_timeout
487
- while True :
488
- try :
489
- retcode = proc .poll ()
490
- # check that the subprocess for the server is not dead
491
- assert retcode is None
492
- conn = urllib .request .urlopen (url )
493
- break
494
- except urllib .error .URLError :
495
- if time .perf_counter () > timeout :
496
- pytest .fail ("Failed to connect to the webagg server." )
497
- else :
498
- continue
499
- conn .close ()
500
- proc .send_signal (signal .SIGINT )
501
- assert proc .wait (timeout = _test_timeout ) == 0
486
+ try :
487
+ while True :
488
+ try :
489
+ retcode = proc .poll ()
490
+ # check that the subprocess for the server is not dead
491
+ assert retcode is None
492
+ conn = urllib .request .urlopen (url )
493
+ break
494
+ except urllib .error .URLError :
495
+ if time .perf_counter () > timeout :
496
+ pytest .fail ("Failed to connect to the webagg server." )
497
+ else :
498
+ continue
499
+ conn .close ()
500
+ proc .send_signal (signal .SIGINT )
501
+ assert proc .wait (timeout = _test_timeout ) == 0
502
+ finally :
503
+ if proc .poll () is None :
504
+ proc .kill ()
502
505
503
506
504
507
def _lazy_headless ():
0 commit comments