Changes in / [481476c:b636dfc5] in sasview
- Location:
- test
- Files:
-
- 3 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
test/fileconverter/test/utest_nxcansas_writer.py
rc476457 r17c9436 66 66 if os.path.isfile(self.write_file_1d): 67 67 os.remove(self.write_file_1d) 68 if os.path.isfile(self.write_file_2d): 69 os.remove(self.write_file_2d) -
test/pr_inversion/test/utest_invertor.py
rac07a3a r17c9436 8 8 9 9 10 import unittest, math, numpy 10 11 import os 12 import unittest 13 import math 14 import numpy 11 15 from sas.sascalc.pr.invertor import Invertor 12 16 17 13 18 class TestFiguresOfMerit(unittest.TestCase): 14 19 … … 416 421 417 422 # Save 418 self.invertor.to_file("test_output.txt") 423 f_name = "test_output.txt" 424 self.invertor.to_file(f_name) 419 425 420 426 # Load 421 self.invertor.from_file( "test_output.txt")427 self.invertor.from_file(f_name) 422 428 self.assertEqual(self.invertor.d_max, 160.0) 423 429 self.assertEqual(self.invertor.alpha, 0.0007) 424 430 self.assertEqual(self.invertor.chi2, 836.797) 425 431 self.assertAlmostEqual(self.invertor.pr(self.invertor.out, 10.0), 903.31577041, 4) 432 if os.path.isfile(f_name): 433 os.remove(f_name) 426 434 427 435 def test_qmin(self): -
test/sasdataloader/test/testplugings.py
r959eb01 r17c9436 3 3 """ 4 4 5 import os 5 6 import unittest 6 7 from sas.sascalc.dataloader.loader import Loader, Registry … … 41 42 # Create module 42 43 import zipfile 43 z = zipfile.PyZipFile("plugins.zip", 'w') 44 f_name = "plugins.zip" 45 z = zipfile.PyZipFile(f_name, 'w') 44 46 z.writepy("../plugins", "") 45 47 z.close() 48 if os.path.isfile(f_name): 49 os.remove(f_name) 46 50 47 51 def testplugin_checksetup(self): -
test/sasdataloader/test/utest_abs_reader.py
rdd11014 r17c9436 339 339 self.assertEqual(self.data.filename, filename) 340 340 self._checkdata() 341 if os.path.isfile(filename): 342 os.remove(filename) 341 343 342 344 def test_units(self): -
test/sasdataloader/test/utest_cansas.py
r7432acb r1fc50fb2 46 46 self.schema_1_0 = "cansas1d_v1_0.xsd" 47 47 self.schema_1_1 = "cansas1d_v1_1.xsd" 48 48 self.write_1_0_filename = "isis_1_0_write_test.xml" 49 self.write_1_1_filename = "isis_1_1_write_test.xml" 49 50 50 51 def get_number_of_entries(self, dictionary, name, i): … … 56 57 return name 57 58 58 59 59 def test_invalid_xml(self): 60 60 """ … … 62 62 """ 63 63 invalid = StringIO.StringIO('<a><c></b></a>') 64 reader = XMLreader(invalid) 65 64 XMLreader(invalid) 66 65 67 66 def test_xml_validate(self): … … 82 81 self.assertFalse(xmlschema.validate(invalid)) 83 82 84 85 83 def test_real_xml(self): 86 84 reader = XMLreader(self.xml_valid, self.schema_1_0) … … 90 88 else: 91 89 self.assertFalse(valid) 92 93 90 94 91 def _check_data(self, data): … … 105 102 self.assertTrue(data.meta_data["xmlpreprocess"] is not None) 106 103 107 108 104 def _check_data_1_1(self, data): 109 105 spectrum = data.trans_spectrum[0] 110 106 self.assertTrue(len(spectrum.wavelength) == 138) 111 107 112 113 108 def test_cansas_xml(self): 114 filename = "isis_1_1_write_test.xml"115 109 xmlreader = XMLreader(self.isis_1_1, self.schema_1_1) 116 110 valid = xmlreader.validate_xml() 117 111 xmlreader.set_processing_instructions() 118 112 self.assertTrue(valid) 119 fo = open(self.isis_1_1)120 str = fo.read()121 113 reader_generic = Loader() 122 114 dataloader = reader_generic.load(self.isis_1_1) … … 128 120 self._check_data(cansasreader[i]) 129 121 self._check_data_1_1(cansasreader[i]) 130 reader_generic.save(filename, dataloader[i], None) 131 fo = open(filename) 132 str = fo.read() 122 reader_generic.save(self.write_1_1_filename, dataloader[i], None) 133 123 reader2 = Loader() 134 return_data = reader2.load(filename) 124 self.assertTrue(os.path.isfile(self.write_1_1_filename)) 125 return_data = reader2.load(self.write_1_1_filename) 135 126 written_data = return_data[0] 136 127 self._check_data(written_data) 137 128 if os.path.isfile(self.write_1_1_filename): 129 os.remove(self.write_1_1_filename) 138 130 139 131 def test_double_trans_spectra(self): … … 144 136 for item in data: 145 137 self._check_data(item) 146 147 138 148 139 def test_entry_name_recurse(self): … … 155 146 self.assertTrue(len(d) == 6) 156 147 157 158 148 def test_load_cansas_file(self): 159 valid = []160 149 reader1 = XMLreader(self.xml_valid, self.schema_1_0) 161 150 self.assertTrue(reader1.validate_xml()) … … 173 162 self.assertFalse(reader7.validate_xml()) 174 163 175 176 164 def test_invalid_cansas(self): 177 165 list = self.loader.load(self.cansas1d_notitle) … … 184 172 self.assertTrue(data.detector[0].distance == 4150) 185 173 186 187 174 def test_old_cansas_files(self): 188 175 reader1 = XMLreader(self.cansas1d, self.schema_1_0) 189 176 self.assertTrue(reader1.validate_xml()) 190 177 file_loader = Loader() 191 file 1 = file_loader.load(self.cansas1d)178 file_loader.load(self.cansas1d) 192 179 reader2 = XMLreader(self.cansas1d_units, self.schema_1_0) 193 180 self.assertTrue(reader2.validate_xml()) … … 197 184 self.assertTrue(reader4.validate_xml()) 198 185 199 200 186 def test_save_cansas_v1_0(self): 201 filename = "isis_1_0_write_test.xml"202 187 xmlreader = XMLreader(self.isis_1_0, self.schema_1_0) 203 188 valid = xmlreader.validate_xml() … … 210 195 self._check_data(dataloader[i]) 211 196 self._check_data(cansasreader[i]) 212 reader_generic.save( filename, dataloader[i], None)197 reader_generic.save(self.write_1_0_filename, dataloader[i], None) 213 198 reader2 = Reader() 214 return_data = reader2.read(filename) 199 self.assertTrue(os.path.isfile(self.write_1_0_filename)) 200 return_data = reader2.read(self.write_1_0_filename) 215 201 written_data = return_data[0] 216 xmlwrite = XMLreader(filename, self.schema_1_0)202 XMLreader(self.write_1_0_filename, self.schema_1_0) 217 203 valid = xmlreader.validate_xml() 218 204 self.assertTrue(valid) 219 205 self._check_data(written_data) 220 206 if os.path.isfile(self.write_1_0_filename): 207 os.remove(self.write_1_0_filename) 221 208 222 209 def test_processing_instructions(self): … … 224 211 valid = reader.validate_xml() 225 212 if valid: 226 # #find the processing instructions and make into a dictionary213 # find the processing instructions and make into a dictionary 227 214 dic = self.get_processing_instructions(reader) 228 215 self.assertTrue(dic == {'xml-stylesheet': \ … … 232 219 xmldoc = minidom.parseString(xml) 233 220 234 # #take the processing instructions and put them back in221 # take the processing instructions and put them back in 235 222 xmldoc = self.set_processing_instructions(xmldoc, dic) 236 xml_output = xmldoc.toprettyxml() 237 223 xmldoc.toprettyxml() 238 224 239 225 def set_processing_instructions(self, minidom_object, dic): … … 243 229 minidom_object.insertBefore(pi, xmlroot) 244 230 return minidom_object 245 246 231 247 232 def get_processing_instructions(self, xml_reader_object):
Note: See TracChangeset
for help on using the changeset viewer.