Changeset cc37c818 in sasview for DataLoader/test


Ignore:
Timestamp:
Jul 11, 2008 8:41:01 AM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
68f6ae2
Parents:
159db3b
Message:

Added test, corrected improper test setup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/test/testLoad.py

    r16d8e5f rcc37c818  
    2121  
    2222import os.path 
     23 
     24class designtest(unittest.TestCase): 
     25     
     26    def setUp(self): 
     27        self.loader = Loader() 
     28         
     29         
     30    def test_singleton(self): 
     31        """ 
     32            Testing whether Loader is truly a singleton 
     33        """ 
     34        # Set a new data member 
     35        self.loader._test_data_member = 1.45 
     36         
     37        # Create a 'new' Loader 
     38        b = Loader() 
     39         
     40        # Test that the new loader has the new data member 
     41        self.assertEqual(b._test_data_member, self.loader._test_data_member) 
     42 
    2343class testLoader(unittest.TestCase): 
    2444    logging.debug("Inside testLoad module") 
     45     
     46    """ test fitting """ 
     47    def setUp(self): 
     48        """ 
     49            Set up the initial conditions before _each_ test 
     50            so that they all start from the same well-defined state.  
     51        """ 
     52        #Creating a loader 
     53        self.L=Loader() 
    2554         
    26     """ test fitting """ 
    27     #Creating a loader 
    28     L=Loader() 
    29      
    30     #creating readers 
    31     read1=TXT2_Reader.Reader() 
    32     read2=TXT3_Reader.Reader() 
    33     read3=IgorReader.Reader() 
    34     read4=danse_reader.Reader() 
    35     read5=tiff_reader.Reader() 
    36     #for each readers set an extensions inside the loader 
    37     L.__setitem__("plugins",'.txt',read2) 
    38     L.__setitem__(None,'.txt',read1) 
    39     L.__setitem__(None,'.dat',read1) 
    40      
    41     L.__setitem__(None,'.dat',read2) 
    42     L.__setitem__(None,'.ASC',read3) 
    43     L.__setitem__(None,'.sans',read4) 
    44     L.__setitem__(None,'.tif',read5) 
    45     L.__setitem__(None,'.jpg',read5) 
    46     L.__setitem__(None,'.png',read5) 
    47     L.__setitem__(None,'.jpeg',read5) 
    48     L.__setitem__(None,'.gif',read5) 
    49     L.__setitem__(None,'.bmp',read5) 
     55        #creating readers 
     56        read1=TXT2_Reader.Reader() 
     57        read2=TXT3_Reader.Reader() 
     58        read3=IgorReader.Reader() 
     59        read4=danse_reader.Reader() 
     60        read5=tiff_reader.Reader() 
     61        #for each readers set an extensions inside the loader 
     62         
     63        #TODO: should not call __setitem__ from outside  
     64        # the class. That's not the purpose of __setitem__ 
     65        self.L.__setitem__("plugins",'.txt',read2) 
     66        self.L.__setitem__(None,'.txt',read1) 
     67        self.L.__setitem__(None,'.dat',read1) 
     68         
     69        self.L.__setitem__(None,'.dat',read2) 
     70        self.L.__setitem__(None,'.ASC',read3) 
     71        self.L.__setitem__(None,'.sans',read4) 
     72        self.L.__setitem__(None,'.tif',read5) 
     73        self.L.__setitem__(None,'.jpg',read5) 
     74        self.L.__setitem__(None,'.png',read5) 
     75        self.L.__setitem__(None,'.jpeg',read5) 
     76        self.L.__setitem__(None,'.gif',read5) 
     77        self.L.__setitem__(None,'.bmp',read5) 
    5078        
    5179    def testLoad0(self): 
     
    135163        """ test file containing an image but as extension .txt""" 
    136164        self.assertEqual(self.L.load('angles_flat.txt'),None) 
     165 
     166if __name__ == '__main__': 
     167    unittest.main() 
    137168    
Note: See TracChangeset for help on using the changeset viewer.