Changeset 6bbe963e in sasview
- Timestamp:
- Apr 14, 2017 4:07:43 PM (8 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 717e456
- Parents:
- 17c9436 (diff), 867aa79 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 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 r17c9436 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() … … 118 112 self.assertTrue(valid) 119 113 fo = open(self.isis_1_1) 120 str = fo.read() 114 fo.read() 115 fo.close() 121 116 reader_generic = Loader() 122 117 dataloader = reader_generic.load(self.isis_1_1) … … 128 123 self._check_data(cansasreader[i]) 129 124 self._check_data_1_1(cansasreader[i]) 130 reader_generic.save(filename, dataloader[i], None) 131 fo = open(filename) 132 str = fo.read() 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() 133 129 reader2 = Loader() 134 return_data = reader2.load( filename)130 return_data = reader2.load(self.write_1_1_filename) 135 131 written_data = return_data[0] 136 132 self._check_data(written_data) 137 133 if os.path.isfile(self.write_1_1_filename): 134 os.remove(self.write_1_1_filename) 138 135 139 136 def test_double_trans_spectra(self): … … 144 141 for item in data: 145 142 self._check_data(item) 146 147 143 148 144 def test_entry_name_recurse(self): … … 155 151 self.assertTrue(len(d) == 6) 156 152 157 158 153 def test_load_cansas_file(self): 159 valid = []160 154 reader1 = XMLreader(self.xml_valid, self.schema_1_0) 161 155 self.assertTrue(reader1.validate_xml()) … … 173 167 self.assertFalse(reader7.validate_xml()) 174 168 175 176 169 def test_invalid_cansas(self): 177 170 list = self.loader.load(self.cansas1d_notitle) … … 184 177 self.assertTrue(data.detector[0].distance == 4150) 185 178 186 187 179 def test_old_cansas_files(self): 188 180 reader1 = XMLreader(self.cansas1d, self.schema_1_0) 189 181 self.assertTrue(reader1.validate_xml()) 190 182 file_loader = Loader() 191 file 1 = file_loader.load(self.cansas1d)183 file_loader.load(self.cansas1d) 192 184 reader2 = XMLreader(self.cansas1d_units, self.schema_1_0) 193 185 self.assertTrue(reader2.validate_xml()) … … 197 189 self.assertTrue(reader4.validate_xml()) 198 190 199 200 191 def test_save_cansas_v1_0(self): 201 filename = "isis_1_0_write_test.xml"202 192 xmlreader = XMLreader(self.isis_1_0, self.schema_1_0) 203 193 valid = xmlreader.validate_xml() … … 210 200 self._check_data(dataloader[i]) 211 201 self._check_data(cansasreader[i]) 212 reader_generic.save( filename, dataloader[i], None)202 reader_generic.save(self.write_1_0_filename, dataloader[i], None) 213 203 reader2 = Reader() 214 return_data = reader2.read( filename)204 return_data = reader2.read(self.write_1_0_filename) 215 205 written_data = return_data[0] 216 xmlwrite = XMLreader(filename, self.schema_1_0)206 XMLreader(self.write_1_0_filename, self.schema_1_0) 217 207 valid = xmlreader.validate_xml() 218 208 self.assertTrue(valid) 219 209 self._check_data(written_data) 220 210 if os.path.isfile(self.write_1_0_filename): 211 os.remove(self.write_1_0_filename) 221 212 222 213 def test_processing_instructions(self): … … 224 215 valid = reader.validate_xml() 225 216 if valid: 226 # #find the processing instructions and make into a dictionary217 # find the processing instructions and make into a dictionary 227 218 dic = self.get_processing_instructions(reader) 228 219 self.assertTrue(dic == {'xml-stylesheet': \ … … 232 223 xmldoc = minidom.parseString(xml) 233 224 234 # #take the processing instructions and put them back in225 # take the processing instructions and put them back in 235 226 xmldoc = self.set_processing_instructions(xmldoc, dic) 236 xml_output = xmldoc.toprettyxml() 237 227 xmldoc.toprettyxml() 238 228 239 229 def set_processing_instructions(self, minidom_object, dic): … … 243 233 minidom_object.insertBefore(pi, xmlroot) 244 234 return minidom_object 245 246 235 247 236 def get_processing_instructions(self, xml_reader_object):
Note: See TracChangeset
for help on using the changeset viewer.