@@ -304,11 +304,12 @@ def test_plot_daily_save_figure(sample_cgm_data):
304304 fig = plot_daily (sample_cgm_data )
305305
306306 with tempfile .NamedTemporaryFile (suffix = '.png' , delete = False ) as tmp_file :
307- fig .savefig (tmp_file .name , dpi = 72 )
308- plt .close (fig )
309- assert os .path .exists (tmp_file .name )
310- assert os .path .getsize (tmp_file .name ) > 0
311- os .unlink (tmp_file .name )
307+ tmp_filename = tmp_file .name
308+ fig .savefig (tmp_filename , dpi = 72 )
309+ plt .close (fig )
310+ assert os .path .exists (tmp_filename )
311+ assert os .path .getsize (tmp_filename ) > 0
312+ os .unlink (tmp_filename )
312313
313314 plt .close (fig )
314315
@@ -420,11 +421,12 @@ def test_plot_statistics_save_figure(multi_day_statistics_data):
420421 fig = plot_statistics (multi_day_statistics_data )
421422
422423 with tempfile .NamedTemporaryFile (suffix = '.png' , delete = False ) as tmp_file :
423- fig .savefig (tmp_file .name , dpi = 72 )
424- plt .close (fig )
425- assert os .path .exists (tmp_file .name )
426- assert os .path .getsize (tmp_file .name ) > 0
427- os .unlink (tmp_file .name )
424+ tmp_filename = tmp_file .name
425+ fig .savefig (tmp_filename , dpi = 72 )
426+ plt .close (fig )
427+ assert os .path .exists (tmp_filename )
428+ assert os .path .getsize (tmp_filename ) > 0
429+ os .unlink (tmp_filename )
428430
429431 plt .close (fig )
430432
@@ -622,11 +624,12 @@ def test_plot_statistics_with_libre_data_save_figure(libre_data):
622624 fig = plot_statistics (libre_data )
623625
624626 with tempfile .NamedTemporaryFile (suffix = '.png' , delete = False ) as tmp_file :
625- fig .savefig (tmp_file .name , dpi = 72 )
626- plt .close (fig )
627- assert os .path .exists (tmp_file .name )
628- assert os .path .getsize (tmp_file .name ) > 0
629- os .unlink (tmp_file .name )
627+ tmp_filename = tmp_file .name
628+ fig .savefig (tmp_filename , dpi = 72 )
629+ plt .close (fig )
630+ assert os .path .exists (tmp_filename )
631+ assert os .path .getsize (tmp_filename ) > 0
632+ os .unlink (tmp_filename )
630633
631634 plt .close (fig )
632635
0 commit comments