Changeset d22da51 in sasview for DataLoader/test


Ignore:
Timestamp:
Jul 9, 2008 3:53:01 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
3dd7cce
Parents:
f8de7de
Message:

clean and more testing added

Location:
DataLoader/test
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/test/testLoad.py

    r1b0b3ca rd22da51  
    11""" 
    22    Unit tests for DataLoader module  
     3    log file "test_log.txt" contains all errors when running loader 
     4    It is create in the folder where test is runned 
    35""" 
     6import logging 
     7logging.basicConfig(level=logging.DEBUG, 
     8                    format='%(asctime)s %(levelname)s %(message)s', 
     9                    filename='test_log.txt', 
     10                    filemode='w') 
     11 
     12 
     13#logger.info('oops I did it again') 
    414 
    515import unittest 
     
    3848    L.__setitem__('.bmp',read5) 
    3949        
     50    def testLoad0(self): 
     51        """test reading empty file""" 
     52        self.assertEqual(self.L.load('empty.txt'),None) 
     53         
    4054    def testLoad1(self): 
    41         """test reading empty file, no file can read it""" 
    42         self.assertEqual(self.L.load('empty.txt'),None) 
    43         self.assertEqual( self.L.getAcTReader('empty.txt'),None) 
    44           
     55        """test reading 2 columns""" 
     56         
    4557        #Testing loading a txt file of 2 columns, the only reader should be read1  
    4658        xload,yload,dyload=self.L.load('test_2_columns.txt')  
     
    5567            self.assertEqual(xload[i],x[i]) 
    5668            self.assertEqual(yload[i],y[i]) 
    57         self.assertEqual( self.L.getAcTReader('test_2_columns.txt'),self.read1.__class__) 
     69        
    5870     
    5971    def testLoad2(self): 
    60         """Testing loading a txt file of 3 columns, the only reader should be read2""" 
     72        """Testing loading a txt file of 3 columns""" 
    6173        xload,yload,dyload= self.L.load('test_3_columns.txt')  
    6274        x=[0,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449]     
     
    7183            self.assertEqual(yload[i],y[i]) 
    7284            self.assertEqual(dyload[i],dy[i]) 
    73         self.assertEqual(self.L.getAcTReader('test_3_columns.txt'),self.read2.__class__) 
     85        
    7486     
    7587    def testload3(self): 
     
    8193        self.assertEqual(ymin,-0.01684257151702391) 
    8294        self.assertEqual(ymax,0.017950440578015116) 
    83         self.assertEqual(self.L.getAcTReader('MAR07232_rest.ASC'),self.read3.__class__) 
     95        
    8496        #tested corrupted file.asc 
    85         self.assertEqual(self.L.load('AR07232_rest.ASC') ,None) 
    86      
     97        try:self.L.load('AR07232_rest.ASC') 
     98        except ValueError,msg: 
     99           #logging.log(10,str(msg)) 
     100           logging.error(str(msg)) 
    87101    def testload4(self): 
    88102        """ Testing loading danse file""" 
     
    91105         
    92106        self.assertEqual(data.__class__,danse_reader.ReaderInfo) 
    93         self.assertEqual(self.L.getAcTReader('MP_New.sans'),self.read4.__class__) 
     107         
    94108        #tested corrupted file.sans 
    95         self.assertEqual(self.L.load('P_New.sans'),None) 
    96      
     109        try: self.L.load('P_New.sans') 
     110        except ValueError,msg: 
     111           #logging.log(40,str(msg)) 
     112           logging.error(str(msg)) 
     113        #else: raise ValueError,"No error raised for missing extension" 
    97114    def testload5(self): 
    98115        """ Testing loading image file""" 
    99116        data=self.L.load('angles_flat.png') 
    100117        self.assertEqual(data.__class__,tiff_reader.ReaderInfo) 
    101         self.assertEqual(self.L.getAcTReader('angles_flat.png'),self.read5.__class__) 
     118         
     119    def testload6(self): 
     120        """test file with unknown extension""" 
     121        try:self.L.load('hello.missing') 
     122        except ValueError,msg: 
     123           self.assertEqual( str(msg),"Unknown file type '.missing'") 
     124        else: raise ValueError,"No error raised for missing extension" 
     125         
     126        #self.L.lookup('hello.missing') 
     127        try: self.L.lookup('hello.missing') 
     128        except ValueError,msg: 
     129           self.assertEqual( str(msg),"Unknown file type '.missing'") 
     130        else: raise ValueError,"No error raised for missing extension" 
     131         
     132    def testload7(self): 
     133        """ test file containing an image but as extension .txt""" 
     134        self.assertEqual(self.L.load('angles_flat.txt'),None) 
    102135    
    103     
  • DataLoader/test/testplugings.py

    r1b0b3ca rd22da51  
    66import math 
    77import DataLoader 
    8 from DataLoader.loader import  SingleLoader 
     8from DataLoader.loader import  Loader 
    99from DataLoader.readers import TXT3_Reader,TXT2_Reader 
    1010from DataLoader.readers import IgorReader,danse_reader,tiff_reader 
     
    1515    def testplugin(self): 
    1616        """ test loading with plugging""" 
    17         l=SingleLoader() 
     17        l=Loader() 
    1818        self.assertEqual(l.__contains__('.tiff'),True) 
    1919        self.assertEqual(l.__contains__('.png'),True) 
    2020        self.assertEqual(l.__contains__('.txt'),True) 
    21         #self.assertEqual(l.getAcTReader('angles_flat.png'),tiff_reader.Reader) 
    22         #self.assertEqual(l.load('angles_flat.png').__class__,tiff_reader.ReaderInfo) 
    23         #print l.load('_THETA_weights.txt')  
     21        
Note: See TracChangeset for help on using the changeset viewer.