1
- import gc
2
1
import os
3
2
from pathlib import Path
3
+ import platform
4
4
import subprocess
5
5
import sys
6
6
import weakref
@@ -87,10 +87,15 @@ def test_null_movie_writer(anim):
87
87
88
88
@pytest .mark .parametrize ('anim' , [dict (klass = dict )], indirect = ['anim' ])
89
89
def test_animation_delete (anim ):
90
+ if platform .python_implementation () == 'PyPy' :
91
+ # Something in the test setup fixture lingers around into the test and
92
+ # breaks pytest.warns on PyPy. This garbage collection fixes it.
93
+ # https://foss.heptapod.net/pypy/pypy/-/issues/3536
94
+ np .testing .break_cycles ()
90
95
anim = animation .FuncAnimation (** anim )
91
96
with pytest .warns (Warning , match = 'Animation was deleted' ):
92
97
del anim
93
- gc . collect ()
98
+ np . testing . break_cycles ()
94
99
95
100
96
101
def test_movie_writer_dpi_default ():
@@ -201,6 +206,11 @@ def test_save_animation_smoketest(tmpdir, writer, frame_format, output, anim):
201
206
])
202
207
@pytest .mark .parametrize ('anim' , [dict (klass = dict )], indirect = ['anim' ])
203
208
def test_animation_repr_html (writer , html , want , anim ):
209
+ if platform .python_implementation () == 'PyPy' :
210
+ # Something in the test setup fixture lingers around into the test and
211
+ # breaks pytest.warns on PyPy. This garbage collection fixes it.
212
+ # https://foss.heptapod.net/pypy/pypy/-/issues/3536
213
+ np .testing .break_cycles ()
204
214
if (writer == 'imagemagick' and html == 'html5'
205
215
# ImageMagick delegates to ffmpeg for this format.
206
216
and not animation .FFMpegWriter .isAvailable ()):
@@ -214,7 +224,8 @@ def test_animation_repr_html(writer, html, want, anim):
214
224
if want is None :
215
225
assert html is None
216
226
with pytest .warns (UserWarning ):
217
- del anim # Animtion was never run, so will warn on cleanup.
227
+ del anim # Animation was never run, so will warn on cleanup.
228
+ np .testing .break_cycles ()
218
229
else :
219
230
assert want in html
220
231
@@ -324,6 +335,7 @@ def frames_generator():
324
335
writer = NullMovieWriter ()
325
336
anim .save ('unused.null' , writer = writer )
326
337
assert len (frames_generated ) == 5
338
+ np .testing .break_cycles ()
327
339
for f in frames_generated :
328
340
# If cache_frame_data is True, then the weakref should be alive;
329
341
# if cache_frame_data is False, then the weakref should be dead (None).
0 commit comments