33
44import  six 
55
6- import  os 
76import  tempfile 
87
98import  numpy  as  np 
10- 
9+ from   nose   import   with_setup 
1110from  matplotlib  import  pyplot  as  plt 
1211from  matplotlib  import  animation 
1312from  matplotlib .testing .noseclasses  import  KnownFailureTest 
14- from  matplotlib .testing .decorators  import  cleanup 
13+ from  matplotlib .testing .decorators  import  CleanupTest 
1514
1615
1716WRITER_OUTPUT  =  dict (ffmpeg = 'mp4' , ffmpeg_file = 'mp4' ,
2322# Smoke test for saving animations.  In the future, we should probably 
2423# design more sophisticated tests which compare resulting frames a-la 
2524# matplotlib.testing.image_comparison 
26- @cleanup  
2725def  test_save_animation_smoketest ():
2826    for  writer , extension  in  six .iteritems (WRITER_OUTPUT ):
2927        yield  check_save_animation , writer , extension 
3028
3129
30+ @with_setup (CleanupTest .setup_class , CleanupTest .teardown_class ) 
3231def  check_save_animation (writer , extension = 'mp4' ):
3332    if  not  animation .writers .is_available (writer ):
3433        raise  KnownFailureTest ("writer '%s' not available on this system" 
3534                               %  writer )
35+     if  'mencoder'  in  writer :
36+         raise  KnownFailureTest ("mencoder is broken" )
3637    fig , ax  =  plt .subplots ()
3738    line , =  ax .plot ([], [])
3839
@@ -49,7 +50,12 @@ def animate(i):
4950    # Use NamedTemporaryFile: will be automatically deleted 
5051    F  =  tempfile .NamedTemporaryFile (suffix = '.'  +  extension )
5152    anim  =  animation .FuncAnimation (fig , animate , init_func = init , frames = 5 )
52-     anim .save (F .name , fps = 30 , writer = writer )
53+     try :
54+         anim .save (F .name , fps = 30 , writer = writer )
55+     except  UnicodeDecodeError :
56+         raise  KnownFailureTest ("There can be errors in the numpy "  + 
57+                                "import stack, "  + 
58+                                "see issues #1891 and #2679" )
5359
5460
5561if  __name__  ==  "__main__" :
0 commit comments