Changeset 286

Show
Ignore:
Timestamp:
11/05/08 11:06:14 (2 months ago)
Author:
bruederle
Message:

Added unit tests for new functions in plotting.py

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/test_plotting.py

    r283 r286  
    88import os 
    99 
     10 
     11 
    1012class PylabParamsTest(unittest.TestCase): 
    1113 
    1214    def runTest(self): 
    13          
     15 
    1416        # define arbitrary values 
    1517        fig_width_pt =  123.4 
     
    4244 
    4345    def runTest(self): 
    44          
     46 
    4547        a = plotting.get_display(True) 
    4648        assert a != None 
     
    4951        a = plotting.get_display(1234) 
    5052        assert a == 1234 
     53 
     54 
     55 
     56class ProgressBarTest(unittest.TestCase): 
     57 
     58    def runTest(self): 
     59 
     60        import time 
     61        print '\nINFO: Testing progress bar...' 
     62        for i in range(100): 
     63            plotting.progress_bar(i/100.) 
     64            time.sleep(.01) 
     65        print '\n' 
     66 
     67 
     68 
     69class Save2DImageTest(unittest.TestCase): 
     70 
     71    def runTest(self): 
     72 
     73        import numpy 
     74        mat = numpy.random.random([50,50]) 
     75        filename = 'deleteme.png' 
     76        if os.path.exists(filename): os.remove(filename) 
     77        plotting.save_2D_image(mat, filename) 
     78        assert os.path.exists(filename) 
     79        os.remove(filename) 
     80 
     81 
     82 
     83class Save2DMovieTest(unittest.TestCase): 
     84 
     85    def runTest(self): 
     86 
     87        import numpy 
     88        frames = [] 
     89        duration = 0.1 
     90        for i in range(10): 
     91            frames.append(numpy.random.randint(0,255,[10,10])) 
     92        filename = 'deleteme.zip' 
     93        if os.path.exists(filename): os.remove(filename) 
     94        plotting.save_2D_movie(frames, filename, duration) 
     95        assert os.path.exists(filename) 
     96        os.remove(filename) 
    5197 
    5298 
     
    98144 
    99145    def setUp(self): 
    100      
     146 
    101147        # define arbitrary values 
    102148        self.nrows = 4 
     
    113159 
    114160    def runTest(self): 
    115      
     161 
    116162        filename = "deleteme.png" 
    117163        if os.path.exists(filename): os.remove(filename) 
     
    125171 
    126172    def runTest(self): 
    127      
     173 
    128174        numPanels = self.nrows * self.ncolumns 
    129175        boollist = [True,False,False,True]