@@ -112,7 +112,7 @@ def isAvailable(self):
112
112
# matplotlib.testing.image_comparison
113
113
@cleanup
114
114
@pytest .mark .parametrize ('writer, extension' , WRITER_OUTPUT )
115
- def test_save_animation_smoketest (writer , extension ):
115
+ def test_save_animation_smoketest (tmpdir , writer , extension ):
116
116
try :
117
117
# for ImageMagick the rcparams must be patched to account for
118
118
# 'convert' being a built in MS tool, not the imagemagick
@@ -138,20 +138,15 @@ def animate(i):
138
138
line .set_data (x , y )
139
139
return line ,
140
140
141
- # Use NamedTemporaryFile: will be automatically deleted
142
- F = tempfile .NamedTemporaryFile (suffix = '.' + extension )
143
- F .close ()
144
- anim = animation .FuncAnimation (fig , animate , init_func = init , frames = 5 )
145
- try :
146
- anim .save (F .name , fps = 30 , writer = writer , bitrate = 500 )
147
- except UnicodeDecodeError :
148
- xfail ("There can be errors in the numpy import stack, "
149
- "see issues #1891 and #2679" )
150
- finally :
141
+ # Use temporary directory for the file-based writers, which produce a file
142
+ # per frame with known names.
143
+ with tmpdir .as_cwd ():
144
+ anim = animation .FuncAnimation (fig , animate , init_func = init , frames = 5 )
151
145
try :
152
- os .remove (F .name )
153
- except Exception :
154
- pass
146
+ anim .save ('movie.' + extension , fps = 30 , writer = writer , bitrate = 500 )
147
+ except UnicodeDecodeError :
148
+ xfail ("There can be errors in the numpy import stack, "
149
+ "see issues #1891 and #2679" )
155
150
156
151
157
152
@cleanup
0 commit comments