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