From 3645c9488b61b66e7a7b2a610de712adcc3deb08 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Thu, 26 Feb 2015 11:04:05 +0000 Subject: [PATCH] Fix tests that used hard coded paths to various files. Refs #11176 --- .../tests/analysis/Diffraction_Workflow_Test.py | 6 +----- .../tests/analysis/DirectInelasticDiagnostic.py | 3 +-- .../tests/analysis/DirectInelasticDiagnostic2.py | 4 +--- .../tests/analysis/LOQSANSUtilityTest.py | 6 +++--- .../SystemTests/tests/analysis/LoadLotsOfFiles.py | 8 ++++++-- .../SystemTests/tests/analysis/ReduceOneSCD_Run.py | 14 ++++---------- .../SystemTests/tests/analysis/SANSLoadersTest.py | 2 +- .../tests/analysis/SNSConvertToMDTest.py | 1 - .../tests/analysis/SpaceGroupFactoryTest.py | 3 ++- 9 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py b/Code/Mantid/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py index c5d88913796..1749239bac9 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py @@ -42,9 +42,6 @@ class Diffraction_Workflow_Test(stresstesting.MantidStressTest): filename = ws+"_event.nxs" LoadEventNexus(Filename=filename,OutputWorkspace=ws,FilterByTofMin='3000',FilterByTofMax='16000') - # Load optimized DetCal file - #LoadIsawDetCal(InputWorkspace=ws,Filename="/SNS/TOPAZ/shared/Spectra/TOPAZ_8Sept11.DetCal") - # Spherical Absorption and Lorentz Corrections AnvredCorrection(InputWorkspace=ws,OutputWorkspace=ws,LinearScatteringCoef="0.451",LinearAbsorptionCoef="0.993",Radius="0.14") @@ -165,8 +162,7 @@ class Diffraction_Workflow_Test(stresstesting.MantidStressTest): # load output hkl file and the golden one LoadHKL(Filename="TOPAZ_3132.hkl", OutputWorkspace="TOPAZ_3132") - LoadHKL(Filename=os.path.join(os.path.dirname(__file__), 'ReferenceResults','TOPAZ_3132_reference.hkl'), - OutputWorkspace="TOPAZ_3132_golden") + LoadHKL(Filename='TOPAZ_3132_reference.hkl', OutputWorkspace="TOPAZ_3132_golden") def validateMethod(self): return "ValidateWorkspaceToWorkspace" diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic.py b/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic.py index 9262949c947..f491e3bedfb 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic.py @@ -63,5 +63,4 @@ class DirectInelasticDiagnostic(MantidStressTest): return 'validateASCII' def validate(self): - return self.saved_diag_file, \ - os.path.join(os.path.dirname(__file__), 'ReferenceResults','DirectInelasticDiagnostic.txt') + return (self.saved_diag_file,'DirectInelasticDiagnostic.txt') diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py b/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py index 238d5c266cd..38ff1f6958f 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py @@ -86,6 +86,4 @@ class DirectInelasticDiagnostic2(MantidStressTest): return 'validateASCII' def validate(self): - return self.saved_diag_file, \ - os.path.join(os.path.dirname(__file__), - 'ReferenceResults', 'DirectInelasticDiagnostic.txt') + return (self.saved_diag_file, 'DirectInelasticDiagnostic.txt') diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/LOQSANSUtilityTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/LOQSANSUtilityTest.py index e98d307ebe6..ecaa625a5e5 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/LOQSANSUtilityTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/LOQSANSUtilityTest.py @@ -15,14 +15,14 @@ class SANSUtilityTest(stresstesting.MantidStressTest): def runTest(self): # created after issue reported in #8156 ws = Load('LOQ54432') - self.assertTrue('Data/LOQ/LOQ54432.raw' in unixLikePathFromWorkspace(ws)) + self.assertTrue('Data/SystemTest/LOQ/LOQ54432.raw' in unixLikePathFromWorkspace(ws)) ws = Load('LOQ99618.RAW') - self.assertTrue('Data/LOQ/LOQ99618.RAW' in unixLikePathFromWorkspace(ws)) + self.assertTrue('Data/SystemTest/LOQ/LOQ99618.RAW' in unixLikePathFromWorkspace(ws)) add.add_runs(('LOQ54432','LOQ54432'),'LOQ','.raw') ws = Load('LOQ54432-add') file_path = unixLikePathFromWorkspace(ws) logger.information("File Path from -add: "+str(file_path)) file_path = file_path.replace('-ADD','-add') # MAC seems to report that the file is LOQ54432-ADD.nxs - self.assertTrue('logs/LOQ54432-add' in file_path) + self.assertTrue('LOQ54432-add' in file_path) os.remove(file_path) diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py b/Code/Mantid/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py index 0a12b119767..f3934442d95 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py @@ -97,14 +97,18 @@ PRIORITY_FILES = ['HYS_13658_event.nxs', def useDir(direc): """Only allow directories that aren't test output or reference results.""" - if "ReferenceResults" in direc: + if "reference" in direc: return False - if "logs" in direc: + if config["defaultsave.directory"] == direc: return False return ("Data" in direc) def useFile(direc, filename): """Returns (useFile, abspath)""" + # if it is an -stamp file then assume these are cmake created files + if filename.endswith("-stamp"): + return (False, filename) + # list of explicitly banned files at the top of this script if filename in BANNED_FILES: return (False, filename) diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py b/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py index 20f26976d16..8f777f68979 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py @@ -39,11 +39,8 @@ class ReduceOneSCD_Run( stresstesting.MantidStressTest): instrument_name = "TOPAZ" calibration_file_1 = "TOPAZ_2011_02_16.DetCal" calibration_file_2 = None - #data_directory = params_dictionary[ "data_directory" ] - import os - self.output_directory = os.path.abspath(os.path.curdir) - # = params_dictionary[ "output_directory" ] + self.output_directory = config["defaultsave.directory"] min_tof = "400" max_tof = "16666" @@ -220,11 +217,11 @@ class ReduceOneSCD_Run( stresstesting.MantidStressTest): LoadIsawUB(InputWorkspace="XX1",Filename=self.run_conventional_matrix_file ) s1 = mtd["XX1"].sample() - LoadIsawPeaks(OutputWorkspace="PeaksP", Filename=os.path.join(os.path.dirname(__file__), 'ReferenceResults',"3132_Orthorhombic_P.integrate")) - LoadIsawUB(InputWorkspace=peaks_ws,Filename=os.path.join(os.path.dirname(__file__), 'ReferenceResults',"3132_Orthorhombic_P.mat")) + LoadIsawPeaks(OutputWorkspace="PeaksP", Filename="3132_Orthorhombic_P.integrate") + LoadIsawUB(InputWorkspace=peaks_ws,Filename="3132_Orthorhombic_P.mat") IndexPeaks( PeaksWorkspace=peaks_ws, Tolerance=tolerance ) CreateSingleValuedWorkspace(OutputWorkspace="XX2",DataValue="3") - LoadIsawUB(InputWorkspace="XX2",Filename=os.path.join(os.path.dirname(__file__), 'ReferenceResults',"3132_Orthorhombic_P.mat")) + LoadIsawUB(InputWorkspace="XX2",Filename="3132_Orthorhombic_P.mat") s2 = mtd["XX2"].sample() ol = s1.getOrientedLattice() @@ -252,6 +249,3 @@ class ReduceOneSCD_Run( stresstesting.MantidStressTest): def validate(self): return [self.__reduced_ws_name,'PeaksP'] - def requiredFiles(self): - - return [os.path.join(os.path.dirname(__file__), 'ReferenceResults',"3132_Orthorhombic_P.integrate"),os.path.join(os.path.dirname(__file__), 'ReferenceResults',"3132_Orthorhombic_P.mat")] diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/SANSLoadersTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/SANSLoadersTest.py index 6bcbcb3ddeb..0de445f4f48 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/SANSLoadersTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/SANSLoadersTest.py @@ -29,7 +29,7 @@ class LoadRunTest(unittest.TestCase): def basicChecks(self, loadRun, file_path, runnum, periods_in_file, ws_name): - self.assertTrue('Data/SANS2D/'+file_path in loadRun._data_file.replace('\\','/'), 'Wrong data file: ' + loadRun._data_file) + self.assertTrue('Data/SystemTest/SANS2D/'+file_path in loadRun._data_file.replace('\\','/'), 'Wrong data file: ' + loadRun._data_file) self.assertEqual(loadRun.periods_in_file, periods_in_file) self.assertEqual(loadRun.wksp_name, ws_name) self.assertEqual(loadRun.shortrun_no, runnum) diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py index c711a171387..4fd364d6f23 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py @@ -186,7 +186,6 @@ class SNSConvertToMDHistProjTest(stresstesting.MantidStressTest): return 2500 def requiredFiles(self): - config.appendDataSearchDir("/home/builder/data/SystemTests/AnalysisTests/ReferenceResults/"); files = [self.truth_file, DATA_FILE] return files diff --git a/Code/Mantid/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py b/Code/Mantid/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py index b3a653e56f1..4f3065ff11e 100644 --- a/Code/Mantid/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py +++ b/Code/Mantid/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py @@ -28,11 +28,12 @@ class SpaceGroupFactoryTest(stresstesting.MantidStressTest): self.assertTrue(groupOperations == referenceOperations, "Problem in space group " + str(group.number()) + " (" + symbol + ")") def loadReferenceData(self): + from mantid.api import FileFinder # Reference data. # Dictionary has a string set for each space group number. separatorMatcher = re.compile("(\d+)") - fileName = os.path.join(os.path.dirname(__file__), 'ReferenceResults','SpaceGroupSymmetryOperations.txt') + fileName = FileFinder.Instance().getFullPath('SpaceGroupSymmetryOperations.txt') print fileName -- GitLab