Changeset f53d684 in sasview for test/sasdataloader
- Timestamp:
- Dec 5, 2017 12:31:07 PM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 5bb05a4
- Parents:
- 3053a4a
- git-author:
- Stuart Prescott <llimeht@…> (12/05/17 12:31:07)
- git-committer:
- Paul Kienzle <pkienzle@…> (12/05/17 12:31:07)
- Location:
- test/sasdataloader/test
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_abs_reader.py
rfe15198 rf53d684 16 16 17 17 18 def find(filename): 19 return os.path.join(os.path.dirname(__file__), filename) 20 21 18 22 class abs_reader(unittest.TestCase): 19 23 20 24 def setUp(self): 21 25 reader = AbsReader() 22 self.data_list = reader.read( "jan08002.ABS")26 self.data_list = reader.read(find("jan08002.ABS")) 23 27 self.data = self.data_list[0] 24 28 … … 31 35 tests won't pass 32 36 """ 33 self.assertEqual( self.data.filename, "jan08002.ABS")37 self.assertEqual(os.path.basename(self.data.filename), "jan08002.ABS") 34 38 self.assertEqual(self.data.meta_data['loader'], "IGOR 1D") 35 39 … … 69 73 def test_generic_loader(self): 70 74 # the generic loader should work as well 71 data = Loader().load( "jan08002.ABS")75 data = Loader().load(find("jan08002.ABS")) 72 76 self.assertEqual(data[0].meta_data['loader'], "IGOR 1D") 73 77 … … 76 80 def setUp(self): 77 81 reader = DANSEReader() 78 self.data_list = reader.read( "MP_New.sans")82 self.data_list = reader.read(find("MP_New.sans")) 79 83 self.data = self.data_list[0] 80 84 … … 88 92 """ 89 93 self.assertEqual(len(self.data_list), 1) 90 self.assertEqual( self.data.filename, "MP_New.sans")94 self.assertEqual(os.path.basename(self.data.filename), "MP_New.sans") 91 95 self.assertEqual(self.data.meta_data['loader'], "DANSE") 92 96 … … 114 118 def test_generic_loader(self): 115 119 # the generic loader should work as well 116 data = Loader().load( "MP_New.sans")120 data = Loader().load(find("MP_New.sans")) 117 121 self.assertEqual(len(data), 1) 118 122 self.assertEqual(data[0].meta_data['loader'], "DANSE") … … 123 127 def setUp(self): 124 128 reader = CANSASReader() 125 self.data_list = reader.read( "cansas1d.xml")129 self.data_list = reader.read(find("cansas1d.xml")) 126 130 self.data = self.data_list[0] 127 131 128 132 def test_generic_loader(self): 129 133 # the generic loader should work as well 130 data = Loader().load( "cansas1d.xml")134 data = Loader().load(find("cansas1d.xml")) 131 135 self.assertEqual(len(data), 1) 132 136 self.assertEqual(data[0].meta_data['loader'], "CanSAS XML 1D") 133 137 134 138 def test_cansas_checkdata(self): 135 self.assertEqual( self.data.filename, "cansas1d.xml")139 self.assertEqual(os.path.basename(self.data.filename), "cansas1d.xml") 136 140 self._checkdata() 137 141 … … 282 286 283 287 filename = "write_test.xml" 284 r.write(fi lename, self.data)285 data = Loader().load(fi lename)288 r.write(find(filename), self.data) 289 data = Loader().load(find(filename)) 286 290 self.data = data[0] 287 291 self.assertEqual(len(data), 1) … … 297 301 """ 298 302 filename = "cansas1d_units.xml" 299 data = CANSASReader().read(fi lename)303 data = CANSASReader().read(find(filename)) 300 304 self.data = data[0] 301 305 self.assertEqual(len(data), 1) … … 309 313 """ 310 314 filename = "cansas1d_badunits.xml" 311 data = CANSASReader().read(fi lename)315 data = CANSASReader().read(find(filename)) 312 316 self.data = data[0] 313 317 self.assertEqual(len(data), 1) … … 326 330 """ 327 331 filename = "cansas1d_slit.xml" 328 data = CANSASReader().read(fi lename)332 data = CANSASReader().read(find(filename)) 329 333 self.data = data[0] 330 334 self.assertEqual(len(data), 1) -
test/sasdataloader/test/utest_ascii.py
rfe15198 rf53d684 2 2 Unit tests for the ascii (n-column) reader 3 3 """ 4 5 import os.path 4 6 import warnings 5 7 warnings.simplefilter("ignore") … … 9 11 10 12 13 def find(filename): 14 return os.path.join(os.path.dirname(__file__), filename) 15 16 11 17 class ABSReaderTests(unittest.TestCase): 12 18 13 19 def setUp(self): 14 20 self.loader = Loader() 15 self.f1_list = self.loader.load( "ascii_test_1.txt")21 self.f1_list = self.loader.load(find("ascii_test_1.txt")) 16 22 self.f1 = self.f1_list[0] 17 self.f2_list = self.loader.load( "ascii_test_2.txt")23 self.f2_list = self.loader.load(find("ascii_test_2.txt")) 18 24 self.f2 = self.f2_list[0] 19 self.f3_list = self.loader.load( "ascii_test_3.txt")25 self.f3_list = self.loader.load(find("ascii_test_3.txt")) 20 26 self.f3 = self.f3_list[0] 21 self.f4_list = self.loader.load( "ascii_test_4.abs")27 self.f4_list = self.loader.load(find("ascii_test_4.abs")) 22 28 self.f4 = self.f4_list[0] 23 self.f5_list = self.loader.load( "ascii_test_5.txt")29 self.f5_list = self.loader.load(find("ascii_test_5.txt")) 24 30 self.f5 = self.f5_list[0] 25 31 … … 99 105 f = None 100 106 try: 101 f = self.loader.load( "ascii_test_6.txt")107 f = self.loader.load(find("ascii_test_6.txt")) 102 108 # The length of the data is 5 103 109 except: -
test/sasdataloader/test/utest_averaging.py
rfe15198 rf53d684 13 13 SlabY, get_q, 14 14 reader2D_converter) 15 16 17 def find(filename): 18 return os.path.join(os.path.dirname(__file__), filename) 15 19 16 20 … … 102 106 103 107 def setUp(self): 104 filepath = os.path.join(os.path.dirname( 105 os.path.realpath(__file__)), 'MAR07232_rest.h5') 108 filepath = find('MAR07232_rest.h5') 106 109 self.data_list = Loader().load(filepath) 107 110 self.data = self.data_list[0] … … 118 121 119 122 o = r(self.data) 120 filepath = os.path.join(os.path.dirname( 121 os.path.realpath(__file__)), 'ring_testdata.txt') 123 filepath = find('ring_testdata.txt') 122 124 answer_list = Loader().load(filepath) 123 125 answer = answer_list[0] … … 140 142 o = r(self.data) 141 143 142 filepath = os.path.join(os.path.dirname( 143 os.path.realpath(__file__)), 'avg_testdata.txt') 144 filepath = find('avg_testdata.txt') 144 145 answer = Loader().load(filepath)[0] 145 146 for i in range(r.nbins_phi): … … 176 177 o = r(self.data) 177 178 178 filepath = os.path.join(os.path.dirname( 179 os.path.realpath(__file__)), 'slabx_testdata.txt') 179 filepath = find('slabx_testdata.txt') 180 180 answer = Loader().load(filepath)[0] 181 181 for i in range(len(o.x)): … … 195 195 o = r(self.data) 196 196 197 filepath = os.path.join(os.path.dirname( 198 os.path.realpath(__file__)), 'slaby_testdata.txt') 197 filepath = find('slaby_testdata.txt') 199 198 answer = Loader().load(filepath)[0] 200 199 for i in range(len(o.x)): … … 222 221 o = r(self.data) 223 222 224 filepath = os.path.join(os.path.dirname( 225 os.path.realpath(__file__)), 'ring_testdata.txt') 223 filepath = find('ring_testdata.txt') 226 224 answer = Loader().load(filepath)[0] 227 225 for i in range(len(o.x)): … … 240 238 o = r(self.data) 241 239 242 filepath = os.path.join(os.path.dirname( 243 os.path.realpath(__file__)), 'sectorphi_testdata.txt') 240 filepath = find('sectorphi_testdata.txt') 244 241 answer = Loader().load(filepath)[0] 245 242 for i in range(len(o.x)): … … 258 255 o = r(self.data) 259 256 260 filepath = os.path.join(os.path.dirname( 261 os.path.realpath(__file__)), 'sectorq_testdata.txt') 257 filepath = find('sectorq_testdata.txt') 262 258 answer = Loader().load(filepath)[0] 263 259 for i in range(len(o.x)): -
test/sasdataloader/test/utest_cansas.py
rf00072f rf53d684 31 31 CANSAS_NS = CansasConstants.CANSAS_NS 32 32 33 34 def find(filename): 35 return os.path.join(os.path.dirname(__file__), filename) 36 37 33 38 class cansas_reader_xml(unittest.TestCase): 34 39 35 40 def setUp(self): 36 41 self.loader = Loader() 37 self.xml_valid = "cansas_test_modified.xml"38 self.xml_invalid = "cansas_test.xml"39 self.cansas1d_badunits = "cansas1d_badunits.xml"40 self.cansas1d = "cansas1d.xml"41 self.cansas1d_slit = "cansas1d_slit.xml"42 self.cansas1d_units = "cansas1d_units.xml"43 self.cansas1d_notitle = "cansas1d_notitle.xml"44 self.isis_1_0 = "ISIS_1_0.xml"45 self.isis_1_1 = "ISIS_1_1.xml"46 self.isis_1_1_notrans = "ISIS_1_1_notrans.xml"47 self.isis_1_1_doubletrans = "ISIS_1_1_doubletrans.xml"48 self.schema_1_0 = "cansas1d_v1_0.xsd"49 self.schema_1_1 = "cansas1d_v1_1.xsd"50 self.write_1_0_filename = "isis_1_0_write_test.xml"51 self.write_1_1_filename = "isis_1_1_write_test.xml"42 self.xml_valid = find("cansas_test_modified.xml") 43 self.xml_invalid = find("cansas_test.xml") 44 self.cansas1d_badunits = find("cansas1d_badunits.xml") 45 self.cansas1d = find("cansas1d.xml") 46 self.cansas1d_slit = find("cansas1d_slit.xml") 47 self.cansas1d_units = find("cansas1d_units.xml") 48 self.cansas1d_notitle = find("cansas1d_notitle.xml") 49 self.isis_1_0 = find("ISIS_1_0.xml") 50 self.isis_1_1 = find("ISIS_1_1.xml") 51 self.isis_1_1_notrans = find("ISIS_1_1_notrans.xml") 52 self.isis_1_1_doubletrans = find("ISIS_1_1_doubletrans.xml") 53 self.schema_1_0 = find("cansas1d_v1_0.xsd") 54 self.schema_1_1 = find("cansas1d_v1_1.xsd") 55 self.write_1_0_filename = find("isis_1_0_write_test.xml") 56 self.write_1_1_filename = find("isis_1_1_write_test.xml") 52 57 53 58 def get_number_of_entries(self, dictionary, name, i): … … 254 259 def setUp(self): 255 260 self.loader = Loader() 256 self.datafile_basic = "simpleexamplefile.h5"257 self.datafile_multiplesasentry = "cansas_1Dand2D_samedatafile.h5"258 self.datafile_multiplesasdata = "cansas_1Dand2D_samesasentry.h5"259 self.datafile_multiplesasdata_multiplesasentry = "cansas_1Dand2D_multiplesasentry_multiplesasdata.h5"261 self.datafile_basic = find("simpleexamplefile.h5") 262 self.datafile_multiplesasentry = find("cansas_1Dand2D_samedatafile.h5") 263 self.datafile_multiplesasdata = find("cansas_1Dand2D_samesasentry.h5") 264 self.datafile_multiplesasdata_multiplesasentry = find("cansas_1Dand2D_multiplesasentry_multiplesasdata.h5") 260 265 261 266 def test_real_data(self): -
test/sasdataloader/test/utest_extension_registry.py
rdcb91cf rf53d684 13 13 logger = logging.getLogger(__name__) 14 14 15 16 def find(filename): 17 return os.path.join(os.path.dirname(__file__), filename) 18 19 15 20 class ExtensionRegistryTests(unittest.TestCase): 16 21 17 22 def setUp(self): 18 self.valid_file = "valid_cansas_xml.xml"19 self.valid_file_wrong_known_ext = "valid_cansas_xml.txt"20 self.valid_file_wrong_unknown_ext = "valid_cansas_xml.xyz"23 self.valid_file = find("valid_cansas_xml.xml") 24 self.valid_file_wrong_known_ext = find("valid_cansas_xml.txt") 25 self.valid_file_wrong_unknown_ext = find("valid_cansas_xml.xyz") 21 26 shutil.copyfile(self.valid_file, self.valid_file_wrong_known_ext) 22 27 shutil.copyfile(self.valid_file, self.valid_file_wrong_unknown_ext) 23 self.invalid_file = "cansas1d_notitle.xml"28 self.invalid_file = find("cansas1d_notitle.xml") 24 29 25 30 self.loader = Loader() -
test/sasdataloader/test/utest_generic_file_reader_class.py
r3648cbf rf53d684 14 14 15 15 16 def find(filename): 17 return os.path.join(os.path.dirname(__file__), filename) 18 19 16 20 class GenericFileReaderTests(unittest.TestCase): 17 21 18 22 def setUp(self): 19 23 self.reader = TestFileReader() 20 self.bad_file = "ACB123.txt"21 self.good_file = "123ABC.txt"24 self.bad_file = find("ACB123.txt") 25 self.good_file = find("123ABC.txt") 22 26 23 27 def test_bad_file_path(self): -
test/sasdataloader/test/utest_red2d_reader.py
rfe15198 rf53d684 10 10 import os.path 11 11 12 13 def find(filename): 14 return os.path.join(os.path.dirname(__file__), filename) 15 16 12 17 class abs_reader(unittest.TestCase): 13 18 14 19 def setUp(self): 15 20 self.loader = Loader() 16 self.data_list = self.loader.load( "exp18_14_igor_2dqxqy.dat")21 self.data_list = self.loader.load(find("exp18_14_igor_2dqxqy.dat")) 17 22 18 23 def test_checkdata(self): -
test/sasdataloader/test/utest_sesans.py
rfe15198 rf53d684 3 3 """ 4 4 5 import os.path 5 6 import unittest 6 7 from sas.sascalc.dataloader.loader_exceptions import FileContentsException,\ … … 8 9 from sas.sascalc.dataloader.readers.sesans_reader import Reader 9 10 from sas.sascalc.dataloader.loader import Loader 11 12 13 def find(filename): 14 return os.path.join(os.path.dirname(__file__), filename) 15 10 16 11 17 class sesans_reader(unittest.TestCase): … … 19 25 Test .SES in the full loader to make sure that the file type is correctly accepted 20 26 """ 21 file = Loader().load( "sesans_examples/sphere2micron.ses")27 file = Loader().load(find("sesans_examples/sphere2micron.ses")) 22 28 f = file[0] 23 29 # self.assertEqual(f, 5) … … 38 44 Test .SES loading on a TOF dataset 39 45 """ 40 file = self.loader( "sesans_examples/sphere_isis.ses")46 file = self.loader(find("sesans_examples/sphere_isis.ses")) 41 47 f = file[0] 42 48 self.assertEqual(len(file), 1) … … 56 62 FileContentsException, 57 63 self.loader, 58 "sesans_examples/sesans_no_data.ses")64 find("sesans_examples/sesans_no_data.ses")) 59 65 60 66 def test_sesans_no_spin_echo_unit(self): … … 65 71 FileContentsException, 66 72 self.loader, 67 "sesans_examples/no_spin_echo_unit.ses")73 find("sesans_examples/no_spin_echo_unit.ses")) 68 74 69 75 def test_sesans_future_version(self): … … 74 80 FileContentsException, 75 81 self.loader, 76 "sesans_examples/next_gen.ses")82 find("sesans_examples/next_gen.ses")) 77 83 78 84 def test_sesans_mandatory_headers(self): … … 83 89 FileContentsException, 84 90 self.loader, 85 "sesans_examples/no_wavelength.ses")91 find("sesans_examples/no_wavelength.ses")) 86 92 87 93 def test_sesans_columns_match_headers(self): … … 92 98 FileContentsException, 93 99 self.loader, 94 "sesans_examples/too_many_headers.ses")100 find("sesans_examples/too_many_headers.ses")) 95 101 96 102 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.