Changes in / [b636dfc5:481476c] 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
r1fc50fb2 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() 111 117 xmlreader.set_processing_instructions() 112 118 self.assertTrue(valid) 119 fo = open(self.isis_1_1) 120 str = fo.read() 113 121 reader_generic = Loader() 114 122 dataloader = reader_generic.load(self.isis_1_1) … … 120 128 self._check_data(cansasreader[i]) 121 129 self._check_data_1_1(cansasreader[i]) 122 reader_generic.save(self.write_1_1_filename, dataloader[i], None) 130 reader_generic.save(filename, dataloader[i], None) 131 fo = open(filename) 132 str = fo.read() 123 133 reader2 = Loader() 124 self.assertTrue(os.path.isfile(self.write_1_1_filename)) 125 return_data = reader2.load(self.write_1_1_filename) 134 return_data = reader2.load(filename) 126 135 written_data = return_data[0] 127 136 self._check_data(written_data) 128 if os.path.isfile(self.write_1_1_filename): 129 os.remove(self.write_1_1_filename) 137 130 138 131 139 def test_double_trans_spectra(self): … … 136 144 for item in data: 137 145 self._check_data(item) 146 138 147 139 148 def test_entry_name_recurse(self): … … 146 155 self.assertTrue(len(d) == 6) 147 156 157 148 158 def test_load_cansas_file(self): 159 valid = [] 149 160 reader1 = XMLreader(self.xml_valid, self.schema_1_0) 150 161 self.assertTrue(reader1.validate_xml()) … … 162 173 self.assertFalse(reader7.validate_xml()) 163 174 175 164 176 def test_invalid_cansas(self): 165 177 list = self.loader.load(self.cansas1d_notitle) … … 172 184 self.assertTrue(data.detector[0].distance == 4150) 173 185 186 174 187 def test_old_cansas_files(self): 175 188 reader1 = XMLreader(self.cansas1d, self.schema_1_0) 176 189 self.assertTrue(reader1.validate_xml()) 177 190 file_loader = Loader() 178 file _loader.load(self.cansas1d)191 file1 = file_loader.load(self.cansas1d) 179 192 reader2 = XMLreader(self.cansas1d_units, self.schema_1_0) 180 193 self.assertTrue(reader2.validate_xml()) … … 184 197 self.assertTrue(reader4.validate_xml()) 185 198 199 186 200 def test_save_cansas_v1_0(self): 201 filename = "isis_1_0_write_test.xml" 187 202 xmlreader = XMLreader(self.isis_1_0, self.schema_1_0) 188 203 valid = xmlreader.validate_xml() … … 195 210 self._check_data(dataloader[i]) 196 211 self._check_data(cansasreader[i]) 197 reader_generic.save( self.write_1_0_filename, dataloader[i], None)212 reader_generic.save(filename, dataloader[i], None) 198 213 reader2 = Reader() 199 self.assertTrue(os.path.isfile(self.write_1_0_filename)) 200 return_data = reader2.read(self.write_1_0_filename) 214 return_data = reader2.read(filename) 201 215 written_data = return_data[0] 202 XMLreader(self.write_1_0_filename, self.schema_1_0)216 xmlwrite = XMLreader(filename, self.schema_1_0) 203 217 valid = xmlreader.validate_xml() 204 218 self.assertTrue(valid) 205 219 self._check_data(written_data) 206 if os.path.isfile(self.write_1_0_filename): 207 os.remove(self.write_1_0_filename) 220 208 221 209 222 def test_processing_instructions(self): … … 211 224 valid = reader.validate_xml() 212 225 if valid: 213 # find the processing instructions and make into a dictionary226 ## find the processing instructions and make into a dictionary 214 227 dic = self.get_processing_instructions(reader) 215 228 self.assertTrue(dic == {'xml-stylesheet': \ … … 219 232 xmldoc = minidom.parseString(xml) 220 233 221 # take the processing instructions and put them back in234 ## take the processing instructions and put them back in 222 235 xmldoc = self.set_processing_instructions(xmldoc, dic) 223 xmldoc.toprettyxml() 236 xml_output = xmldoc.toprettyxml() 237 224 238 225 239 def set_processing_instructions(self, minidom_object, dic): … … 229 243 minidom_object.insertBefore(pi, xmlroot) 230 244 return minidom_object 245 231 246 232 247 def get_processing_instructions(self, xml_reader_object):
Note: See TracChangeset
for help on using the changeset viewer.