Changeset d22da51 in sasview for DataLoader/test
- Timestamp:
- Jul 9, 2008 3:53:01 PM (16 years ago)
- 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
- Location:
- DataLoader/test
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/test/testLoad.py
r1b0b3ca rd22da51 1 1 """ 2 2 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 3 5 """ 6 import logging 7 logging.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') 4 14 5 15 import unittest … … 38 48 L.__setitem__('.bmp',read5) 39 49 50 def testLoad0(self): 51 """test reading empty file""" 52 self.assertEqual(self.L.load('empty.txt'),None) 53 40 54 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 45 57 #Testing loading a txt file of 2 columns, the only reader should be read1 46 58 xload,yload,dyload=self.L.load('test_2_columns.txt') … … 55 67 self.assertEqual(xload[i],x[i]) 56 68 self.assertEqual(yload[i],y[i]) 57 self.assertEqual( self.L.getAcTReader('test_2_columns.txt'),self.read1.__class__)69 58 70 59 71 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""" 61 73 xload,yload,dyload= self.L.load('test_3_columns.txt') 62 74 x=[0,0.204082,0.408163,0.612245,0.816327,1.02041,1.22449] … … 71 83 self.assertEqual(yload[i],y[i]) 72 84 self.assertEqual(dyload[i],dy[i]) 73 self.assertEqual(self.L.getAcTReader('test_3_columns.txt'),self.read2.__class__)85 74 86 75 87 def testload3(self): … … 81 93 self.assertEqual(ymin,-0.01684257151702391) 82 94 self.assertEqual(ymax,0.017950440578015116) 83 self.assertEqual(self.L.getAcTReader('MAR07232_rest.ASC'),self.read3.__class__)95 84 96 #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)) 87 101 def testload4(self): 88 102 """ Testing loading danse file""" … … 91 105 92 106 self.assertEqual(data.__class__,danse_reader.ReaderInfo) 93 self.assertEqual(self.L.getAcTReader('MP_New.sans'),self.read4.__class__)107 94 108 #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" 97 114 def testload5(self): 98 115 """ Testing loading image file""" 99 116 data=self.L.load('angles_flat.png') 100 117 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) 102 135 103 -
DataLoader/test/testplugings.py
r1b0b3ca rd22da51 6 6 import math 7 7 import DataLoader 8 from DataLoader.loader import SingleLoader8 from DataLoader.loader import Loader 9 9 from DataLoader.readers import TXT3_Reader,TXT2_Reader 10 10 from DataLoader.readers import IgorReader,danse_reader,tiff_reader … … 15 15 def testplugin(self): 16 16 """ test loading with plugging""" 17 l= SingleLoader()17 l=Loader() 18 18 self.assertEqual(l.__contains__('.tiff'),True) 19 19 self.assertEqual(l.__contains__('.png'),True) 20 20 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.