- Timestamp:
- Sep 13, 2017 10:27:29 AM (7 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- fca1f50
- Parents:
- b76e65a (diff), 7b3f154 (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. - Location:
- test
- Files:
-
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sasdataloader/test/utest_abs_reader.py
rce8c7bd ra78a02f 20 20 def setUp(self): 21 21 reader = AbsReader() 22 self.data = reader.read("jan08002.ABS") 22 data = reader.read("jan08002.ABS") 23 self.data= data[0] 23 24 24 25 def test_abs_checkdata(self): … … 47 48 self.assertEqual(self.data.detector[0].beam_center.y, center_y) 48 49 49 self.assertEqual(self.data.y_unit, ' 1/cm')50 self.assertEqual(self.data.y_unit, 'cm^{-1}') 50 51 self.assertEqual(self.data.x[0], 0.002618) 51 52 self.assertEqual(self.data.x[1], 0.007854) … … 69 70 # the generic loader should work as well 70 71 data = Loader().load("jan08002.ABS") 71 self.assertEqual(data .meta_data['loader'], "IGOR 1D")72 self.assertEqual(data[0].meta_data['loader'], "IGOR 1D") 72 73 73 74 class DanseReaderTests(unittest.TestCase): … … 75 76 def setUp(self): 76 77 reader = DANSEReader() 77 self.data = reader.read("MP_New.sans") 78 data = reader.read("MP_New.sans") 79 self.data = data[0] 78 80 79 81 def test_checkdata(self): … … 112 114 # the generic loader should work as well 113 115 data = Loader().load("MP_New.sans") 114 self.assertEqual(data .meta_data['loader'], "DANSE")116 self.assertEqual(data[0].meta_data['loader'], "DANSE") 115 117 116 118 … … 144 146 # Data 145 147 self.assertEqual(len(self.data.x), 2) 146 self.assertEqual(self.data.x_unit, ' 1/A')147 self.assertEqual(self.data.y_unit, ' 1/cm')148 self.assertEqual(self.data.x_unit, 'A^{-1}') 149 self.assertEqual(self.data.y_unit, 'cm^{-1}') 148 150 self.assertAlmostEqual(self.data.x[0], 0.02, 6) 149 151 self.assertAlmostEqual(self.data.y[0], 1000, 6) … … 257 259 self.assertTrue(item.date in ['04-Sep-2007 18:35:02', 258 260 '03-SEP-2006 11:42:47']) 259 print(item.term)260 261 for t in item.term: 261 262 if (t['name'] == "ABS:DSTAND" … … 309 310 310 311 self.assertEqual(self.data.meta_data['loader'], "CanSAS XML 1D") 311 print(self.data.errors) 312 self.assertEqual(len(self.data.errors), 1) 312 self.assertEqual(len(self.data.errors), 0) 313 313 314 314 def test_slits(self): … … 324 324 # Data 325 325 self.assertEqual(len(self.data.x), 2) 326 self.assertEqual(self.data.x_unit, ' 1/A')327 self.assertEqual(self.data.y_unit, ' 1/cm')326 self.assertEqual(self.data.x_unit, 'A^{-1}') 327 self.assertEqual(self.data.y_unit, 'cm^{-1}') 328 328 self.assertEqual(self.data.x[0], 0.02) 329 329 self.assertEqual(self.data.y[0], 1000) … … 333 333 self.assertEqual(self.data.x[1], 0.03) 334 334 self.assertAlmostEquals(self.data.y[1], 1001.0) 335 self.assertEqual(self.data.dx , None)335 self.assertEqual(self.data.dx[0], 0.0) 336 336 self.assertEqual(self.data.dxl[1], 0.005) 337 337 self.assertEqual(self.data.dxw[1], 0.001) -
test/sasdataloader/test/utest_ascii.py
rad92c5a ra78a02f 32 32 self.assertEqual(self.f1.x[0],0.002618) 33 33 self.assertEqual(self.f1.x[9],0.0497) 34 self.assert Equal(self.f1.x_unit, '1/A')35 self.assert Equal(self.f1.y_unit, '1/cm')34 self.assertTrue(self.f1.x_unit == 'A^{-1}') 35 self.assertTrue(self.f1.y_unit == 'cm^{-1}') 36 36 37 37 self.assertEqual(self.f1.meta_data['loader'],"ASCII") -
test/sasdataloader/test/utest_cansas.py
r1fc50fb2 r17e257b5 20 20 21 21 from lxml import etree 22 from lxml.etree import XMLSyntaxError 22 23 from xml.dom import minidom 23 24 … … 62 63 """ 63 64 invalid = StringIO.StringIO('<a><c></b></a>') 64 XMLreader(invalid)65 self.assertRaises(XMLSyntaxError, lambda: XMLreader(invalid)) 65 66 66 67 def test_xml_validate(self): … … 302 303 self.assertTrue(data._yunit == "cm^{-1}") 303 304 self.assertTrue(data.y.size == 100) 304 self.assertAlmostEqual(data.y[ 9], 0.952749011516985)305 self.assertAlmostEqual(data.x[ 9], 0.3834415188257777)305 self.assertAlmostEqual(data.y[40], 0.952749011516985) 306 self.assertAlmostEqual(data.x[40], 0.3834415188257777) 306 307 self.assertAlmostEqual(len(data.meta_data), 0) 307 308 -
test/sasdataloader/test/utest_sesans.py
ra67c494 ra78a02f 4 4 5 5 import unittest 6 from sas.sascalc.dataloader.loader_exceptions import FileContentsException,\ 7 DefaultReaderException 6 8 from sas.sascalc.dataloader.readers.sesans_reader import Reader 7 9 from sas.sascalc.dataloader.loader import Loader … … 17 19 Test .SES in the full loader to make sure that the file type is correctly accepted 18 20 """ 19 f = Loader().load("sesans_examples/sphere2micron.ses") 21 file = Loader().load("sesans_examples/sphere2micron.ses") 22 f = file[0] 20 23 # self.assertEqual(f, 5) 21 24 self.assertEqual(len(f.x), 40) … … 34 37 Test .SES loading on a TOF dataset 35 38 """ 36 f = self.loader("sesans_examples/sphere_isis.ses") 39 file = self.loader("sesans_examples/sphere_isis.ses") 40 f = file[0] 37 41 self.assertEqual(len(f.x), 57) 38 42 self.assertEqual(f.x[-1], 19303.4) … … 48 52 """ 49 53 self.assertRaises( 50 RuntimeError,54 FileContentsException, 51 55 self.loader, 52 56 "sesans_examples/sesans_no_data.ses") … … 57 61 """ 58 62 self.assertRaises( 59 RuntimeError,63 FileContentsException, 60 64 self.loader, 61 65 "sesans_examples/no_spin_echo_unit.ses") 62 63 def test_sesans_no_version(self):64 """65 Confirm that sesans files with no file format version raise an appropriate error66 """67 self.assertRaises(68 RuntimeError,69 self.loader,70 "sesans_examples/no_version.ses")71 66 72 67 def test_sesans_future_version(self): … … 75 70 """ 76 71 self.assertRaises( 77 RuntimeError,72 FileContentsException, 78 73 self.loader, 79 74 "sesans_examples/next_gen.ses") … … 84 79 """ 85 80 self.assertRaises( 86 RuntimeError,81 FileContentsException, 87 82 self.loader, 88 83 "sesans_examples/no_wavelength.ses") … … 93 88 """ 94 89 self.assertRaises( 95 RuntimeError,90 FileContentsException, 96 91 self.loader, 97 92 "sesans_examples/too_many_headers.ses") -
test/utest_sasview.py
raaf5e49 rb54440d 44 44 n_errors = 0 45 45 n_failures = 0 46 46 47 47 for d in (dirs if dirs else os.listdir(test_root)): 48 48 49 49 # Check for modules to be skipped 50 50 if d in SKIPPED_DIRS: 51 51 continue 52 52 53 53 54 54 # Go through modules looking for unit tests … … 64 64 #print std_out 65 65 #sys.exit() 66 has_failed = True67 66 m = re.search("Ran ([0-9]+) test", std_out) 68 67 if m is not None: 69 has_failed = False70 68 n_tests += int(m.group(1)) 69 has_tests = True 70 else: 71 has_tests = False 71 72 72 m = re.search("FAILED \(errors=([0-9]+)\)", std_out) 73 has_failed = "FAILED (" in std_out 74 m = re.search("FAILED \(.*errors=([0-9]+)", std_out) 73 75 if m is not None: 74 has_failed = True75 76 n_errors += int(m.group(1)) 76 77 m = re.search("FAILED \(failures=([0-9]+)\)", std_out) 77 m = re.search("FAILED \(.*failures=([0-9]+)", std_out) 78 78 if m is not None: 79 has_failed = True80 79 n_failures += int(m.group(1)) 81 82 if has_failed :80 81 if has_failed or not has_tests: 83 82 failed += 1 84 83 print("Result for %s (%s): FAILED" % (module_name, module_dir)) … … 102 101 print(" Test errors: %d" % n_errors) 103 102 print("----------------------------------------------") 104 103 105 104 return failed 106 105 … … 110 109 if run_tests(dirs=dirs, all=all)>0: 111 110 sys.exit(1) 112 111 -
test/corfunc/test/utest_corfunc.py
r253eb6c6 r968d67e 17 17 upperq=(0.15, 0.24)) 18 18 self.extrapolation = None 19 self.transformation = None 19 20 20 21 def extrapolate(self):
Note: See TracChangeset
for help on using the changeset viewer.