6
6
import os
7
7
import sys
8
8
import tempfile
9
+
9
10
import numpy as np
10
- from numpy . testing import assert_equal
11
- from nose . tools import assert_false , assert_true
11
+ import pytest
12
+
12
13
import matplotlib as mpl
13
14
from matplotlib import pyplot as plt
14
15
from matplotlib import animation
@@ -67,12 +68,12 @@ def animate(i):
67
68
anim .save (filename , dpi = dpi , writer = writer ,
68
69
savefig_kwargs = savefig_kwargs )
69
70
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
76
77
77
78
78
79
@animation .writers .register ('null' )
@@ -93,23 +94,25 @@ def isAvailable(self):
93
94
return True
94
95
95
96
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
+ ]
101
108
102
109
103
110
# Smoke test for saving animations. In the future, we should probably
104
111
# design more sophisticated tests which compare resulting frames a-la
105
112
# 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
-
111
113
@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 ):
113
116
try :
114
117
# for ImageMagick the rcparams must be patched to account for
115
118
# 'convert' being a built in MS tool, not the imagemagick
@@ -174,26 +177,21 @@ def test_movie_writer_registry():
174
177
ffmpeg_path = mpl .rcParams ['animation.ffmpeg_path' ]
175
178
# Not sure about the first state as there could be some writer
176
179
# 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
179
182
animation .writers .list () # resets dirty state
180
- assert_false ( animation .writers ._dirty )
183
+ assert not animation .writers ._dirty
181
184
mpl .rcParams ['animation.ffmpeg_path' ] = u"not_available_ever_xxxx"
182
- assert_true ( animation .writers ._dirty )
185
+ assert animation .writers ._dirty
183
186
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" )
186
189
# something which is guaranteed to be available in path
187
190
# and exits immediately
188
191
bin = u"true" if sys .platform != 'win32' else u"where"
189
192
mpl .rcParams ['animation.ffmpeg_path' ] = bin
190
- assert_true ( animation .writers ._dirty )
193
+ assert animation .writers ._dirty
191
194
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" )
194
197
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