66import os
77import sys
88import tempfile
9+
910import numpy as np
10- from numpy . testing import assert_equal
11- from nose . tools import assert_false , assert_true
11+ import pytest
12+
1213import matplotlib as mpl
1314from matplotlib import pyplot as plt
1415from matplotlib import animation
@@ -67,12 +68,12 @@ def animate(i):
6768 anim .save (filename , dpi = dpi , writer = writer ,
6869 savefig_kwargs = savefig_kwargs )
6970
70- assert_equal ( writer .fig , fig )
71- assert_equal ( writer .outfile , filename )
72- assert_equal ( writer .dpi , dpi )
73- assert_equal ( writer .args , () )
74- assert_equal ( writer .savefig_kwargs , savefig_kwargs )
75- assert_equal ( writer ._count , num_frames )
71+ assert writer .fig == fig
72+ assert writer .outfile == filename
73+ assert writer .dpi == dpi
74+ assert writer .args == ( )
75+ assert writer .savefig_kwargs == savefig_kwargs
76+ assert writer ._count == num_frames
7677
7778
7879@animation .writers .register ('null' )
@@ -93,23 +94,25 @@ def isAvailable(self):
9394 return True
9495
9596
96- WRITER_OUTPUT = dict (ffmpeg = 'mp4' , ffmpeg_file = 'mp4' ,
97- mencoder = 'mp4' , mencoder_file = 'mp4' ,
98- avconv = 'mp4' , avconv_file = 'mp4' ,
99- imagemagick = 'gif' , imagemagick_file = 'gif' ,
100- null = 'null' )
97+ WRITER_OUTPUT = [
98+ ('ffmpeg' , 'mp4' ),
99+ ('ffmpeg_file' , 'mp4' ),
100+ ('mencoder' , 'mp4' ),
101+ ('mencoder_file' , 'mp4' ),
102+ ('avconv' , 'mp4' ),
103+ ('avconv_file' , 'mp4' ),
104+ ('imagemagick' , 'gif' ),
105+ ('imagemagick_file' , 'gif' ),
106+ ('null' , 'null' )
107+ ]
101108
102109
103110# Smoke test for saving animations. In the future, we should probably
104111# design more sophisticated tests which compare resulting frames a-la
105112# matplotlib.testing.image_comparison
106- def test_save_animation_smoketest ():
107- for writer , extension in six .iteritems (WRITER_OUTPUT ):
108- yield check_save_animation , writer , extension
109-
110-
111113@cleanup
112- def check_save_animation (writer , extension = 'mp4' ):
114+ @pytest .mark .parametrize ('writer, extension' , WRITER_OUTPUT )
115+ def test_save_animation_smoketest (writer , extension ):
113116 try :
114117 # for ImageMagick the rcparams must be patched to account for
115118 # 'convert' being a built in MS tool, not the imagemagick
@@ -174,26 +177,21 @@ def test_movie_writer_registry():
174177 ffmpeg_path = mpl .rcParams ['animation.ffmpeg_path' ]
175178 # Not sure about the first state as there could be some writer
176179 # which set rcparams
177- #assert_false( animation.writers._dirty)
178- assert_true ( len (animation .writers ._registered ) > 0 )
180+ # assert not animation.writers._dirty
181+ assert len (animation .writers ._registered ) > 0
179182 animation .writers .list () # resets dirty state
180- assert_false ( animation .writers ._dirty )
183+ assert not animation .writers ._dirty
181184 mpl .rcParams ['animation.ffmpeg_path' ] = u"not_available_ever_xxxx"
182- assert_true ( animation .writers ._dirty )
185+ assert animation .writers ._dirty
183186 animation .writers .list () # resets
184- assert_false ( animation .writers ._dirty )
185- assert_false ( animation .writers .is_available ("ffmpeg" ) )
187+ assert not animation .writers ._dirty
188+ assert not animation .writers .is_available ("ffmpeg" )
186189 # something which is guaranteed to be available in path
187190 # and exits immediately
188191 bin = u"true" if sys .platform != 'win32' else u"where"
189192 mpl .rcParams ['animation.ffmpeg_path' ] = bin
190- assert_true ( animation .writers ._dirty )
193+ assert animation .writers ._dirty
191194 animation .writers .list () # resets
192- assert_false ( animation .writers ._dirty )
193- assert_true ( animation .writers .is_available ("ffmpeg" ) )
195+ assert not animation .writers ._dirty
196+ assert animation .writers .is_available ("ffmpeg" )
194197 mpl .rcParams ['animation.ffmpeg_path' ] = ffmpeg_path
195-
196-
197- if __name__ == "__main__" :
198- import nose
199- nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments