@@ -195,20 +195,16 @@ def psfont(*args, **kwargs):
195195 fig .savefig (tmpfile , format = 'pdf' )
196196
197197
198- def test_pdf_savefig_when_color_is_none ():
199- backup_params = mpl . rcParams . copy ()
200- mpl . rcParams . update ( mpl . rcParamsDefault )
198+ @ pytest . fixture ( scope = 'function' )
199+ def test_pdf_savefig_when_color_is_none ( tempdir_factory ):
200+ rcParams [ '_internal.classic_mode' ] = False
201201 plt .subplot ()
202202 plt .axis ('off' )
203203 plt .plot (np .sin (np .linspace (- 5 , 5 , 100 )), 'v' , c = 'none' )
204- try :
205- plt . savefig ( "figure.pdf" , format = ' pdf' )
206- except Exception :
207- pytest . fail ( "Failed to save pdf" )
208- plt .savefig ("figure.eps" , format = 'eps' )
209- result = compare_images ('figure.pdf' , 'figure.eps' , 0 )
204+ tmpdir_name = str ( np . random . randint ( 100000 , 10000000 ))
205+ actual_image = tempdir_factory . mktemp ( tmpdir_name ). join ( 'figure. pdf' )
206+ expected_image = tempdir_factory . mktemp ( tmpdir_name ). join ( 'figure.eps' )
207+ plt . savefig ( str ( actual_image ), format = ' pdf' )
208+ plt .savefig (str ( expected_image ) , format = 'eps' )
209+ result = compare_images (str ( actual_image ), str ( expected_image ) , 0 )
210210 assert result is None
211- from os import remove
212- remove ('figure.eps' )
213- remove ('figure.pdf' )
214- mpl .rcParams .update (backup_params )
0 commit comments