er == 'imagemagick' and html == 'html5' # ImageMagick delegates to ffmpeg for this format. and not animation.FFMpegWriter.isAvailable()): pytest.skip('Requires FFMpeg') # create here rather than in the fixture otherwise we get __del__ warnings # about producing no output anim = animation.FuncAnimation(**anim) with plt.rc_context({'animation.writer': writer, 'animation.html': html}): html = anim._repr_html_() if want is None: assert html is None with pytest.warns(UserWarning): del anim # Animation was never run, so will warn on cleanup. np.testing.break_cycles() else: assert want in html @pytest.mark.parametrize( 'anim', [{'save_count': 10, 'frames': iter(range(5))}], indirect=['anim'] ) def test_no_length_frames(anim): anim.save('unused.null', writer=NullMovieWriter()) def test_movie_writer_registry(): assert len(animation.writers._registered) > 0 mpl.rcParams['animation.ffmpeg_path'] = "not_available_ever_xxxx" assert not animation.writers.is_available("ffmpeg") # something guaranteed to be available in path and exits immediately bin = "true" if sys.platform != 'win32' else "where" mpl.rcParams['animation.ffmpeg_path'] = bin assert animation.writers.is_available("ffmpeg") @pytest.mark.parametrize( "method_name", [pytest.param("to_html5_video", marks=pytest.mark.skipif( not animation.writers.is_available(mpl.rcParams["animation.writer"]), reason="animation writer not installed")), "to_jshtml"]) @pytest.mark.parametrize('anim', [dict(frames=1)], indirect=['anim']) def test_embed_limit(method_name, caplog, tmpdir, anim): caplog.set_level("WARNING") with tmpdir.as_cwd(): with mpl.rc_context({"animation.embed_limit": 1e-6}): # ~1 byte. getattr(anim, method_name)() assert len(caplog.rec