source: sasview/DataLoader/test/testplugings.py @ 579ba85

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 579ba85 was 4c00964, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

Working on cansas writer

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[1b0b3ca]1"""
2    Unit tests for DataLoader module
3"""
4
5import unittest
6import math
7import DataLoader
[d22da51]8from DataLoader.loader import  Loader
[1b0b3ca]9from DataLoader.readers import TXT3_Reader,TXT2_Reader
10from DataLoader.readers import IgorReader,danse_reader,tiff_reader
11import os.path
12import os 
[d3619421]13import logging
14logging.basicConfig(level=logging.DEBUG,
15                    format='%(asctime)s %(levelname)s %(message)s',
16                    filename='test_log.txt',
17                    filemode='w')
[1b0b3ca]18class testLoader(unittest.TestCase):
[d3619421]19   
20    try:L=Loader()
21    except AttributeError,msg:
22        logging.warning(msg)
[1b0b3ca]23    def testplugin(self):
[2fd516b]24        """ test loading with readers"""
25       
26        self.assertEqual(self.L.__contains__('.tiff'),True)
27        self.assertEqual(self.L.__contains__('.png'),True)
28        self.assertEqual(self.L.__contains__('.txt'),True)
[d3619421]29         #tested corrupted file.asc
30        try:self.L.load('MAR07232_rest.ASC')
31        except AttributeError,msg:
32           #logging.log(10,str(msg))
33           logging.warning(str(msg))
[2fd516b]34    def testplugin1(self):
[1b0b3ca]35        """ test loading with plugging"""
[2fd516b]36        self.L.__setitem__(dir='plugins')
[94daf8a]37        read3=IgorReader.Reader()
38        self.L.__setitem__('plugins','.ASC',read3)
39        self.assertEqual(self.L.__contains__('.ASC'),True)
[2fd516b]40        #Testing loading a txt file of 2 columns, the only reader should be read1
[16d8e5f]41        output=self.L.load('test_2_columns.txt') 
[2fd516b]42        x=[2.83954,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449,1.42857,1.63265]
43        y=[0.6,3.44938, 5.82026,5.27591,5.2781,5.22531,7.47487,7.85852,10.2278]
44        dx=[]
45        dy=[]
[16d8e5f]46        self.assertEqual(len(output.x),len(x))
47        self.assertEqual(len(output.y),len(y))
48       
[2fd516b]49        for i in range(len(x)):
[16d8e5f]50            self.assertEqual(output.x[i],x[i])
51            self.assertEqual(output.y[i],y[i])
[4c00964]52
53# How about actually executing the tests...
54if __name__ == '__main__':
55    unittest.main()
Note: See TracBrowser for help on using the repository browser.