diff --git a/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py b/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py index a046c1c697e7b1a09f0591ad7dc237912c1a2ac6..bc7ae01dde8c82067bfd7ce5bcf05ea1c2efb7b9 100644 --- a/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py +++ b/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py @@ -37,13 +37,13 @@ class SimpleAPITest(unittest.TestCase): # of attributes as unique algorithms module_dict = dir(simpleapi) all_algs = AlgorithmFactory.getRegisteredAlgorithms(True) - self.assertTrue(len(module_dict) > len(all_algs)) + self.assertGreater(len(module_dict), len(all_algs)) def test_alg_has_expected_doc_string(self): # Test auto generated string, Load is manually written expected_doc = """Rebins data with new X bin boundaries. For EventWorkspaces, you can very quickly rebin in-place by keeping the same output name and PreserveEvents=true.\n\nProperty descriptions: \n\nInputWorkspace(Input:req) *MatrixWorkspace* Workspace containing the input data\n\nOutputWorkspace(Output:req) *MatrixWorkspace* The name to give the output workspace\n\nParams(Input:req) *dbl list* A comma separated list of first bin boundary, width, last bin boundary. Optionally this can be followed by a comma and more widths and last boundary pairs. Optionally this can also be a single number, which is the bin width. In this case, the boundary of binning will be determined by minimum and maximum TOF values among all events, or previous binning boundary, in case of event Workspace, or non-event Workspace, respectively. Negative width values indicate logarithmic binning. \n\nPreserveEvents(Input) *boolean* Keep the output workspace as an EventWorkspace, if the input has events. If the input and output EventWorkspace names are the same, only the X bins are set, which is very quick. If false, then the workspace gets converted to a Workspace2D histogram.\n\nFullBinsOnly(Input) *boolean* Omit the final bin if it's width is smaller than the step size\n\nIgnoreBinErrors(Input) *boolean* Ignore errors related to zero/negative bin widths in input/output workspaces. When ignored, the signal and errors are set to zero\n""" doc = simpleapi.rebin.__doc__ - self.assertTrue(len(doc) > 0) + self.assertGreater(len(doc), 0) self.assertEqual(doc, expected_doc) def test_function_call_executes_correct_algorithm_when_passed_correct_args(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py b/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py index 90e4231ec350abdbb68b3e6194759ebdd6885406..0df12e8bb1d214b56db76fe61f1c4dae437000b0 100644 --- a/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py @@ -27,7 +27,7 @@ class DeprecatedAlgorithmCheckerTest(unittest.TestCase): def test_deprecated_algorithm_returns_non_empty_string_from_isDeprecated(self): deprecation_check = DeprecatedAlgorithmChecker("DiffractionFocussing",1) msg = deprecation_check.isDeprecated() - self.assertTrue(len(msg) > 0) + self.assertGreater(len(msg), 0) if __name__ == '__main__': diff --git a/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py b/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py index d7fe49d661ff68897046d43032a00f83c98113b1..8552373c9a5380869feab3fd6d918d94e82e5f92 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py @@ -16,7 +16,7 @@ class FileFinderTest(unittest.TestCase): def test_full_path_returns_an_absolute_path_and_the_files_exists(self): path = FileFinder.getFullPath("CNCS_7860_event.nxs") - self.assertTrue(len(path) > 0) + self.assertGreater(len(path), 0) # We can't be sure what the full path is in general but it should certainly exist! self.assertTrue(os.path.exists(path)) @@ -32,8 +32,8 @@ class FileFinderTest(unittest.TestCase): FileFinder.findRuns("CNCS7860", [".nxs", ".txt"], useExtsOnly=True) except Exception as e: if type(e).__name__ == "ArgumentError": - self.assertFalse(True, "Expected findRuns to accept a list of strings and a bool as input." - " {} error was raised with message {}".format(type(e).__name__, str(e))) + self.fail("Expected findRuns to accept a list of strings and a bool as input." + " {} error was raised with message {}".format(type(e).__name__, str(e))) else: # Confirm that it works as above self.assertEqual(len(runs), 1) diff --git a/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py b/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py index 30d5f4abf23c07ecbff1890f81863067bfc50b24..cae32f38b10e8d2b289753010d0bc644cfaec9b5 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py @@ -54,7 +54,7 @@ class FunctionFactoryTest(unittest.TestCase): name = "Gaussian" func = FunctionFactory.createFunction(name) self.assertEqual(func.name(), name) - self.assertTrue(len(func.__repr__()) > len(name)) + self.assertGreater(len(func.__repr__()), len(name)) self.assertTrue("Peak" in func.categories()) def test_function_subscription_of_non_class_type_raises_error(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py b/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py index de65b218dd1ceb907cb1eb77df7bc2657077b60a..24bab20410ff3aa044dd7c130688284490aa2a7e 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py @@ -74,7 +74,7 @@ class MDGeometryTest(unittest.TestCase): def test_getGeometryXML_returns_non_empty_string(self): xml = self._test_mdws.getGeometryXML() - self.assertTrue(len(xml) > 0) + self.assertGreater(len(xml), 0) def test_getBasisVector_returns_VMD(self): basis = self._test_mdws.getBasisVector(0) diff --git a/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py index 39b0f622a26086f2154c9c38c301848841241ae4..7b0c4e42c8b1e1f38d0ae4fe764e7d846dd9cc4d 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py @@ -42,7 +42,7 @@ class MatrixWorkspaceTest(unittest.TestCase): self.assertEquals(self._test_ws.getTitle(), "Test histogram") self.assertEquals(self._test_ws.getComment(), "") self.assertEquals(self._test_ws.isDirty(), False) - self.assertTrue(self._test_ws.getMemorySize() > 0.0) + self.assertGreater(self._test_ws.getMemorySize(), 0.0) self.assertEquals(self._test_ws.threadSafe(), True) def test_workspace_data_information(self): @@ -108,7 +108,7 @@ class MatrixWorkspaceTest(unittest.TestCase): # Have got a MatrixWorkspace back and not just the generic interface self.assertTrue(isinstance(propValue, MatrixWorkspace)) mem = propValue.getMemorySize() - self.assertTrue((mem > 0)) + self.assertGreater((mem, 0)) AnalysisDataService.remove(wsname) @@ -121,7 +121,7 @@ class MatrixWorkspaceTest(unittest.TestCase): # Have got a MatrixWorkspace back and not just the generic interface self.assertTrue(isinstance(value, MatrixWorkspace)) mem = value.getMemorySize() - self.assertTrue((mem > 0)) + self.assertGreater((mem, 0)) AnalysisDataService.remove(wsname) diff --git a/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py b/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py index 694a9a84d27c81fcc6182801bce98479362f5609..42ac671e47e4905d9aad7633f73c9ebc40b6d9e1 100644 --- a/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py @@ -162,7 +162,7 @@ class SpectrumInfoTest(unittest.TestCase): self.assertAlmostEquals(pos.X(), 0) self.assertAlmostEquals(pos.Z(), 5) if(lastY): - self.assertTrue(pos.Y() > lastY) + self.assertGreater(pos.Y(), lastY) lastY = pos.Y() """ diff --git a/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py b/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py index 6ac48ff2ca9019af362b1cf84c3b9d275cb93fbb..2ba71f65673aea9b8ebbb981e14892d3db5f60de 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py @@ -507,7 +507,7 @@ class ComponentInfoTest(unittest.TestCase): source_pos = comp_info.sourcePosition() it = iter(comp_info) # basic check on first detector position - self.assertTrue(next(it).position.distance(source_pos) > 0) + self.assertGreater(next(it).position.distance(source_pos), 0) def test_children_via_iterator(self): info = self._ws.componentInfo() diff --git a/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py b/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py index 53a95af1d85bc159f9dd5a94030f95b15d431fb3..1315198f3d2d3d120b626d70c142c8afd092b5da 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py @@ -167,13 +167,13 @@ class DetectorInfoTest(unittest.TestCase): self.assertAlmostEquals(pos.X(), 0) self.assertAlmostEquals(pos.Z(), 5) if(lastY): - self.assertTrue(pos.Y() > lastY) + self.assertGreater(pos.Y(), lastY) lastY = pos.Y() def test_iterator_for_l2(self): info = self._ws.detectorInfo() for item in info: - self.assertTrue(item.l2 > 0) + self.assertGreater(item.l2, 0) """ ---------------------------------------------------------------------------- diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py index 05f1c0f512bd79727c10db48907a75ff24f4c7c7..ac7b8a85edca30e4cac8a9aef04c582220c01fcd 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py @@ -48,7 +48,7 @@ class ConfigServiceTest(unittest.TestCase): facilities = config.getFacilities() names = config.getFacilityNames() - self.assertTrue(len(names)>0) + self.assertGreater(len(names), 0) self.assertEquals(len(names),len(facilities)) for i in range(len(names)): self.assertEquals(names[i],facilities[i].name()) diff --git a/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py b/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py index e7241af926fd41f4683f3c4aac31cc1a3c9e4044..cfd5fbf621cdf0f3d1ec31f9d6accc2f7c00d217 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py @@ -27,7 +27,7 @@ class FacilityInfoTest(unittest.TestCase): self.assertEquals(len(test_facility.extensions()), 7) self.assertEquals(test_facility.preferredExtension(), ".nxs") self.assertEquals(len(test_facility.archiveSearch()), 1) - self.assertTrue(len(test_facility.instruments()) > 30) + self.assertGreater(len(test_facility.instruments()), 30) self.assertTrue(len(test_facility.instruments("Neutron Diffraction"))> 10) self.assertTrue(isinstance(test_facility.instrument("WISH"), InstrumentInfo)) self.assertEquals(test_facility.timezone(), "Europe/London") diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py index 3836be11ef458f84b3e804d3d0e14126f2271ea7..243c0299d813061ba6c9e3faace928644a900185 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py @@ -36,7 +36,7 @@ class PropertyWithValueTest(unittest.TestCase): def test_type_str_is_not_empty(self): rangeLower=self.__class__._integration.getProperty("RangeLower") - self.assertTrue(len(rangeLower.type) > 0) + self.assertGreater(len(rangeLower.type), 0) def test_getproperty_value_returns_derived_type(self): data = [1.0,2.0,3.0] diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py index 5fc1ea953afeafa9305ca66548dea42f88eed7bd..2b18b3964016ba356e656039eefb7ec0648f0df3 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py @@ -51,7 +51,7 @@ class PythonPluginsTest(unittest.TestCase): def test_loading_python_algorithm_increases_registered_algs_by_one(self): loaded = plugins.load(self._testdir) - self.assertTrue(len(loaded) > 0) + self.assertGreater(len(loaded), 0) expected_name = 'TestPyAlg' # Has the name appear in the module dictionary self.assertTrue(expected_name in sys.modules) diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py index 13c7d0b74e460265a1e98186cedd0d1a80b94b02..b7bdc7df3eb26b86cff74d812b79393543e923b1 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py @@ -32,7 +32,7 @@ class UnitFactoryTest(unittest.TestCase): 'Energy_inWavenumber', 'dSpacing', 'MomentumTransfer', 'QSquared', 'DeltaE', 'DeltaE_inWavenumber', 'DeltaE_inFrequency', 'Momentum', 'dSpacingPerpendicular'] - self.assertTrue(len(core_units) <= len(known_units)) + self.assertLessEqual(len(core_units), len(known_units)) for unit in core_units: self.assertTrue(unit in known_units, "%s unit not found in UnitFactory keys" % unit) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py index 0366a3417a1d8cd506ede7a880e44f470c689041..82996a83865800d3e3c1596f47b6331578675f68 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py @@ -20,8 +20,8 @@ class CropWorkspaceForMDNormTest(unittest.TestCase): XMin=1, XMax=6) self.assertEquals(ws_out.getNumberEvents(), ws_in.getNumberEvents()/2) - self.assertTrue(ws_out.getSpectrum(1).getTofs().max()<=6.) - self.assertTrue(ws_out.getSpectrum(1).getTofs().min()>=1.) + self.assertLessEqual(ws_out.getSpectrum(1).getTofs().max(), 6.) + self.assertGreaterEqual(ws_out.getSpectrum(1).getTofs().min(), 1.) self.assertTrue(ws_out.run().hasProperty('MDNorm_low')) self.assertTrue(ws_out.run().hasProperty('MDNorm_high')) self.assertTrue(ws_out.run().hasProperty('MDNorm_spectra_index')) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py index 52afb2606066b11352f66e9e47d93ec025403a7d..d131323b535c1aa9e8595fbc1f4c52211eba2f1b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py @@ -51,7 +51,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 2) @@ -122,7 +122,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 3) @@ -181,7 +181,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 3) @@ -246,7 +246,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 2) @@ -310,7 +310,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 2) @@ -388,7 +388,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 4) @@ -401,8 +401,8 @@ class ExportExperimentLogTest(unittest.TestCase): nextline = lines[i+1] next_run = int(nextline.split(',')[0]) next_min = float(nextline.split(',')[2]) - self.assertTrue(curr_run < next_run) - self.assertTrue(curr_min < next_min) + self.assertLess(curr_run, next_run) + self.assertLess(curr_min, next_min) # Remove generated files @@ -504,7 +504,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 4) @@ -517,8 +517,8 @@ class ExportExperimentLogTest(unittest.TestCase): nextline = lines[i+1] next_run = int(nextline.split('\t')[0]) next_min = float(nextline.split('\t')[2]) - self.assertTrue(curr_run < next_run) - self.assertTrue(curr_min < next_min) + self.assertLess(curr_run, next_run) + self.assertLess(curr_min, next_min) line2 = lines[2] terms = line2.split("\t") @@ -600,7 +600,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 4) @@ -613,8 +613,8 @@ class ExportExperimentLogTest(unittest.TestCase): nextline = lines[i+1] next_run = int(nextline.split('\t')[0]) next_min = float(nextline.split('\t')[2]) - self.assertTrue(curr_run < next_run) - self.assertTrue(curr_min < next_min) + self.assertLess(curr_run, next_run) + self.assertLess(curr_min, next_min) line2 = lines[2] terms = line2.split("\t") @@ -665,7 +665,7 @@ class ExportExperimentLogTest(unittest.TestCase): # Last line cannot be empty, i.e., before EOF '\n' is not allowed lastline = lines[-1] - self.assertTrue(len(lastline.strip()) > 0) + self.assertGreater(len(lastline.strip()), 0) # Number of lines self.assertEquals(len(lines), 2) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py index c7e7e7c16d8a5e12c046fbfc616c4b503b42423c..d39bed5e42e904263f85575185ea72da3e5172d4 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py @@ -62,8 +62,8 @@ class FitGaussianTest(unittest.TestCase): diffPeakCentre = abs((fitPeakCentre - peakCentre) / peakCentre) diffSigma = abs((fitSigma - sigma) / sigma) - self.assertTrue(diffPeakCentre < 0.03) - self.assertTrue(diffSigma < 1e-6) + self.assertLess(diffPeakCentre, 0.03) + self.assertLess(diffSigma, 1e-6) def test_guessedPeaks(self): """Test that generated Gaussian peaks are reasonably well guessed. diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py index 917b6d9abdc3e69d8df3c7026c8d8fbdb5537fb6..3813b958adc36eac6795f1d9afb3e93a0c9dd93c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py @@ -43,8 +43,8 @@ class LRPeakSelectionTest(unittest.TestCase): diff_peak_centre = abs((position - peak_center) / peak_center) diff_sigma = abs((width - sigma) / sigma) - self.assertTrue(diff_peak_centre < 0.03) - self.assertTrue(diff_sigma < 0.05) + self.assertLess(diff_peak_centre, 0.03) + self.assertLess(diff_sigma, 0.05) def test_primary_range(self): """ @@ -63,12 +63,12 @@ class LRPeakSelectionTest(unittest.TestCase): diff_peak_centre = abs((position - peak_center) / peak_center) diff_sigma = abs((width - sigma) / sigma) - self.assertTrue(diff_peak_centre < 0.03) - self.assertTrue(diff_sigma < 0.05) + self.assertLess(diff_peak_centre, 0.03) + self.assertLess(diff_sigma, 0.05) # The low resolution range should fit within the primary range - self.assertTrue(primary_range[0] < low_res[0]) - self.assertTrue(primary_range[1] > low_res[1]) + self.assertLess(primary_range[0], low_res[0]) + self.assertGreater(primary_range[1], low_res[1]) if __name__ == "__main__": unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py index dab8c500ab399fbc4864a274a737e5891ec0d869..e3ab82f0c6ed46f6b669044314b1d080b5a3578a 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py @@ -55,11 +55,11 @@ class NormaliseSpectraTest(unittest.TestCase): def _check_spectrum_less_than(self, y_data, upper_boundary): for i in range(len(y_data)): - self.assertTrue(y_data[i] <= upper_boundary) + self.assertLessEqual(y_data[i], upper_boundary) def _check_spectrum_more_than(self, y_data, lower_boundary): for i in range(len(y_data)): - self.assertTrue(y_data[i] >= lower_boundary) + self.assertGreaterEqual(y_data[i], lower_boundary) #--------------------------------Helper Functions----------------------------------------- def _create_workspace(self, nhists, out_name, data_string): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py index 3db8fa702c2728a632cbf78b60bfde33c40e4979..b7fe9057de696981dd44a2c83556d745f60d96b7 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py @@ -48,8 +48,8 @@ class SANSWideAngleCorrectionTest(unittest.TestCase): hRange = Max(correction) lRange = Transpose(lRange) hRange = Transpose(hRange) - self.assertTrue(97 > hRange.dataY(0).all()) - self.assertTrue(1 >= hRange.dataY(0).all()) + self.assertGreater(97, hRange.dataY(0).all()) + self.assertGreaterEqual(1, hRange.dataY(0).all()) def test_negative_trans_data(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py index e09cc01ec6093ddb612f77cf9d0eaff562830f15..0bab9a2a6acfaabd11b9159ea6096274de7b1938 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py @@ -89,7 +89,7 @@ class SaveNexusPDTest(unittest.TestCase): nxmoderator = nxinstrument['moderator'] if withInstrument: - self.assertTrue(nxmoderator['distance'][0] < 0.) + self.assertLess(nxmoderator['distance'][0], 0.) for name in nxinstrument.keys(): if name == 'moderator': diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py index 0853ccd8ff884ac677a52d4d352d964d265e4f97..4ac5ee8c85aca37d3679a7d3d1d330fe1ca7decc 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py @@ -32,7 +32,7 @@ class StringToPngTest(unittest.TestCase): ok2run = 'Problem importing matplotlib' if ok2run == '': simpleapi.StringToPng(String=to_plot, OutputFilename=self.plotfile) - self.assertTrue(os.path.getsize(self.plotfile) > 1e3) + self.assertGreater(os.path.getsize(self.plotfile), 1e3) self.cleanup() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py index ce70e06b632533e221f014ed95cbd1bd4f6476d3..416903c67799dc1a3637f0127b3d125690576100 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py @@ -67,7 +67,7 @@ class SymmetriseTest(unittest.TestCase): data_x = workspace.dataX(0) for idx in range(0, int(len(data_x) / 2)): delta = abs(data_x[idx]) - abs(data_x[-(idx + 1)]) - self.assertTrue(abs(delta) < tolerance) + self.assertLess(abs(delta), tolerance) # Test that the axis and values were preserved sample_x_axis = self._sample_ws.getAxis(0) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py index d6dfe2d65f08288bc69ffe12c7e97d8da1f51c9f..d1ce03d3c3134b3238ebfd7d543794ceeecb3c29 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py @@ -36,8 +36,8 @@ class TOFTOFCropWorkspaceTest(unittest.TestCase): # check their values full_channels = float(run.getLogData('full_channels').value) channel_width = float(run.getLogData('channel_width').value) - self.assertTrue(full_channels > 0.) - self.assertTrue(channel_width > 0.) + self.assertGreater(full_channels, 0.) + self.assertGreater(channel_width, 0.) # check unit horizontal axis self.assertEqual(self._cropped_ws.getAxis(0).getUnit().unitID(), 'TOF') # check length of cropped ws diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py index 3e14e6a704a4c6b063e378eedfa46f51bb2e734c..c6358478f918234c86e2068f113ed9b1f45cd535 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py @@ -198,7 +198,7 @@ class ApplyPaalmanPingsCorrectionTest(unittest.TestCase): corrected = ApplyPaalmanPingsCorrection(SampleWorkspace=sample_1, CanWorkspace=container_1, RebinCanToSample=True) - self.assertTrue(numpy.all(sample_1.extractY() > corrected.extractY())) + self.assertGreater(numpy.all(sample_1.extractY(), corrected.extractY())) DeleteWorkspace(sample_1) DeleteWorkspace(container_1) DeleteWorkspace(corrected) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py index 695a18ee607f32cc1df5401f930e16357a3b57e7..36ee2a100e89e1bea6104a77bf39ce84bb1eba38 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py @@ -70,7 +70,7 @@ class MolDynTest(unittest.TestCase): x_max = x_data[len(x_data) - 1] # Check that it is less that what was passed to algorithm - self.assertTrue(x_max <= 1.0) + self.assertLessEqual(x_max, 1.0) def test_loadSqwWithSymm(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py index 96b8cb6ea0e81aed42337933e707e49765ec290f..15981dd9a12257d7e29eb7a5b1e9274755e61666 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py @@ -65,7 +65,7 @@ class SavePlot1DTest(unittest.TestCase): self.makeWs() div = simpleapi.SavePlot1D(InputWorkspace='test1', OutputType='plotly') self.cleanup() - self.assertTrue(len(div) > 0) # confirm result is non-empty + self.assertGreater(len(div), 0) # confirm result is non-empty @unittest.skipIf(not havePlotly, 'Do not have plotly installed') @@ -73,7 +73,7 @@ class SavePlot1DTest(unittest.TestCase): self.makeWs() div = simpleapi.SavePlot1D(InputWorkspace='group', OutputType='plotly') self.cleanup() - self.assertTrue(len(div) > 0) # confirm result is non-empty + self.assertGreater(len(div), 0) # confirm result is non-empty if __name__ == "__main__": diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSCalculateTransmissionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSCalculateTransmissionTest.py index 42c8de3c5051550be52d35bb576390ab7fc262bc..0daf5a5a11cd2244d47e9d88a107d30acb428611 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSCalculateTransmissionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSCalculateTransmissionTest.py @@ -267,7 +267,7 @@ class SANSCalculateTransmissionTest(unittest.TestCase): for e1, e2 in zip(unfitted_workspace.dataY(0), ratio): self.assertTrue(abs(e1 - e2) < tolerance) - self.assertTrue(e1 <= 1.0) # The transmission has to be smaller or equal to 1 + self.assertLessEqual(e1, 1.0) # The transmission has to be smaller or equal to 1 def test_that_calculates_transmission_for_general_background_and_no_prompt_peak(self): # Arrange diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSNormalizeToMonitorTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSNormalizeToMonitorTest.py index 72d5d3e9852501d60322f4cec60cc67e3b700b82..ee04905692d1436c4a4fc0b11210c56de579c117 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSNormalizeToMonitorTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSNormalizeToMonitorTest.py @@ -148,7 +148,7 @@ class SANSNormalizeToMonitorTest(unittest.TestCase): for e1, e2, in zip(workspace.dataX(0), expected_lambda): self.assertTrue(abs(e1 - e2) < tolerance) for e1, e2, in zip(workspace.dataY(0), expected_signal): - self.assertTrue(abs(e1-e2) < tolerance) + self.assertLess(abs(e1-e2), tolerance) def test_that_gets_normalization_for_general_background_and_no_prompt_peak(self): # Arrange diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSSliceEventTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSSliceEventTest.py index 87c5768d0bf6aa7330957157c74011428c894c23..9d0d7d838e0f631944d6c55c4a510abda2415aa6 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSSliceEventTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSSliceEventTest.py @@ -118,8 +118,8 @@ class SANSSliceEventTest(unittest.TestCase): # Assert self.assertEqual(slice_factor, 0.2) - self.assertTrue(output_workspace.getNumberEvents() < workspace.getNumberEvents()) - self.assertTrue(output_workspace_monitor.dataY(0)[0] < monitor_workspace.dataY(0)[0]) + self.assertLess(output_workspace.getNumberEvents(), workspace.getNumberEvents()) + self.assertLess(output_workspace_monitor.dataY(0)[0], monitor_workspace.dataY(0)[0]) if __name__ == '__main__': diff --git a/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py b/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py index 60d8a67f96cb467bd61df3d2df335a877315a1a9..391c3600fcb73bfc16bae71ec6d60fcee8faea27 100644 --- a/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py +++ b/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py @@ -370,7 +370,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.00001) + self.assertLess(math.fabs(delta), 0.00001) def test_reduction_iqxqy(self): ''' @@ -425,7 +425,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): 0.1000351,0.10489929,0.11] deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.00001) + self.assertLess(math.fabs(delta), 0.00001) print(data) def test_no_solid_angle(self): @@ -481,7 +481,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.00001) + self.assertLess(math.fabs(delta), 0.00001) def test_straight_Q1D(self): GPSANS() @@ -514,7 +514,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.00001) + self.assertLess(math.fabs(delta), 0.00001) def test_transmission(self): GPSANS() @@ -550,7 +550,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.001) + self.assertLess(math.fabs(delta), 0.001) def test_spreader_transmission(self): GPSANS() @@ -703,7 +703,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): # Check that I(q) is the same for both data sets deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.00001) + self.assertLess(math.fabs(delta), 0.00001) def test_SampleGeometry_functions(self): print("SKIPPING test_SampleGeometry_functions()") @@ -734,7 +734,7 @@ class HFIRTestsAPIv2(systemtesting.MantidSystemTest): # Check that I(q) is the same for both data sets deltas = list(map(_diff_iq, data, check)) delta = reduce(_add, deltas) / len(deltas) - self.assertTrue(math.fabs(delta) < 0.1) + self.assertLess(math.fabs(delta), 0.1) def test_noDC_eff_with_DC(self): ref = [28.06525, 136.94662, -16.20412, 0.00000, 147.79915, 146.42713, 302.00869, diff --git a/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py b/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py index 1a9cf9f87a46cf6d87c8d147d38ea5c1e2b99b7d..33b45cde221a0f7c362e44f0b9232b19eaf53da1 100644 --- a/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py +++ b/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py @@ -38,9 +38,9 @@ class ILLPowderD2BEfficiencyTest(systemtesting.MantidSystemTest): data = mtd['masked'].extractY().flatten() data = data[np.nonzero(data)] coeff_max = data.max() - self.assertTrue(coeff_max <= 3.) + self.assertLessEqual(coeff_max, 3.) coeff_min = data.min() - self.assertTrue(coeff_min >= 0.3) + self.assertGreaterEqual(coeff_min, 0.3) def runTest(self): diff --git a/Testing/SystemTests/tests/analysis/POLDILoadRunsTest.py b/Testing/SystemTests/tests/analysis/POLDILoadRunsTest.py index a1bfcd534f4ec18eb2ac704c9d2109b6523dd98c..9f9c94e11130b165025616b9e9d1ff201564de80 100644 --- a/Testing/SystemTests/tests/analysis/POLDILoadRunsTest.py +++ b/Testing/SystemTests/tests/analysis/POLDILoadRunsTest.py @@ -79,14 +79,14 @@ class POLDILoadRunsTest(systemtesting.MantidSystemTest): PoldiLoadRuns(2013, 6903, 6904, 3, OutputWorkspace="threeWorkspacesFail") self.fail() except: - self.assertTrue(True) + pass def loadWorkspacesNotFound(self): try: PoldiLoadRuns(1990, 6903, OutputWorkspace="notFound") self.fail() except: - self.assertTrue(True) + pass def loadWorkspacesAddToGroup(self): wsGroup = PoldiLoadRuns(2013, 6903) diff --git a/Testing/SystemTests/tests/analysis/POLDIMergeTest.py b/Testing/SystemTests/tests/analysis/POLDIMergeTest.py index 1fa34155c4afc08d860a4d24e59debc47a26cd34..9c284dfeef870221e06ac7ce590fbe42e4ab8dcb 100644 --- a/Testing/SystemTests/tests/analysis/POLDIMergeTest.py +++ b/Testing/SystemTests/tests/analysis/POLDIMergeTest.py @@ -25,7 +25,7 @@ class POLDIMergeTest(systemtesting.MantidSystemTest): self.runPoldiMerge(dataFiles, "Dummy") self.fail() except RuntimeError: - self.assertTrue(True) + pass def testHappyCase(self): dataFiles = ["poldi2013n006903", "poldi2013n006904"] diff --git a/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py b/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py index 45e0fa9b05f5f383d33a945df8b22557a119e6d9..f850e3e02ff1d983fa3ff3917b4ab06af292f8f1 100644 --- a/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py +++ b/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py @@ -84,8 +84,8 @@ class GlobalFitTest(MantidSystemTest): # Validate self._success = True try: - self.assertTrue(chi2 < 1) # goodness of fit - self.assertTrue(abs(params.row(6)["Value"]-1.58)/1.58 < 0.1) # optimal DiffCoeff + self.assertLess(chi2, 1) # goodness of fit + self.assertLess(abs(params.row(6)["Value"]-1.58)/1.58, 0.1) # optimal DiffCoeff self.assertTrue(abs(params.row(7)["Value"] - 1.16) / 1.16 < 0.1) # optimal Tau # check curves are correctly generated by calculating their Chi^2 residuals = np.empty(0) @@ -96,7 +96,7 @@ class GlobalFitTest(MantidSystemTest): modelY = curveset.dataY(1) residuals = np.append(residuals, ((dataY-modelY)/dataE)**2) # don't trust residuals of curveset otherChi2 = residuals.sum()/len(residuals) - self.assertTrue(abs(otherChi2-chi2)/chi2 < 0.1) + self.assertLess(abs(otherChi2-chi2)/chi2, 0.1) except: self._success = False diff --git a/Testing/SystemTests/tests/analysis/ReflectometryISIS.py b/Testing/SystemTests/tests/analysis/ReflectometryISIS.py index 4bdde40d9b73b2c8dae9514f39314a32f029998a..235f7562d101672bb07641467cfa5f433036b72c 100644 --- a/Testing/SystemTests/tests/analysis/ReflectometryISIS.py +++ b/Testing/SystemTests/tests/analysis/ReflectometryISIS.py @@ -60,7 +60,7 @@ class ReflectometryISIS(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)) thisTheta = ws1.detectorSignedTwoTheta(ws1.getDetector(i)) nextTheta = ws1.detectorSignedTwoTheta(ws1.getDetector(i+1)) #This check would fail if negative values were being normalised. - self.assertTrue(thisTheta < nextTheta) + self.assertLess(thisTheta, nextTheta) # MD transformations QxQy, _QxQy_vertexes = ConvertToReflectometryQ(InputWorkspace='SignedTheta_vs_Wavelength', diff --git a/Testing/SystemTests/tests/analysis/SANSSaveTest.py b/Testing/SystemTests/tests/analysis/SANSSaveTest.py index c69c993b4e4070317fb5bbbe0ad0ae6a07f0c5b4..0fef0d6cc0892bba106c99c5dcfa687821369cb7 100644 --- a/Testing/SystemTests/tests/analysis/SANSSaveTest.py +++ b/Testing/SystemTests/tests/analysis/SANSSaveTest.py @@ -177,9 +177,9 @@ class SANSSaveTest(unittest.TestCase): reloaded_workspace = load_alg.getProperty("OutputWorkspace").value errors = reloaded_workspace.dataE(0) # Make sure that the errors are not zero - self.assertTrue(errors[0] > 1.0) - self.assertTrue(errors[14] > 1.0) - self.assertTrue(errors[45] > 1.0) + self.assertGreater(errors[0], 1.0) + self.assertGreater(errors[14], 1.0) + self.assertGreater(errors[45], 1.0) # Clean up self._remove_file(file_name) diff --git a/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py b/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py index 225bbf999c9ec6f51d13b27b427727fd88ebd7e9..1551ec8c73e10b60a48f8db39fb7cef8d61d96fe 100644 --- a/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py +++ b/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py @@ -86,7 +86,7 @@ def _equal_within_tolerance(self, expected, actual, tolerance=0.05): """ tolerance_value = expected * tolerance abs_difference = abs(expected - actual) - self.assertTrue(abs_difference <= abs(tolerance_value), + self.assertLessEqual(abs_difference, abs(tolerance_value), msg="abs({:.6f} - {:.6f}) > {:.6f}".format(expected, actual, tolerance)) diff --git a/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py b/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py index 85fa6944d5e282e5be459a9d6e94d4e02bf10a92..807f5c8d4aacdc4186c4a020c3aa8df92b7e99e7 100644 --- a/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py +++ b/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py @@ -602,7 +602,7 @@ def _validate_table_values_top_to_bottom(self, table_ws, expected_values, tolera if expected_values[i] != 'skip': tolerance_value = expected_values[i] * tolerance abs_difference = abs(expected_values[i] - table_ws.cell(i, 1)) - self.assertTrue(abs_difference <= abs(tolerance_value), + self.assertLessEqual(abs_difference, abs(tolerance_value), msg="Expected Value in Cell " + str(i) + ": " + str(expected_values[i]) + "\nActual Value in Cell " + str(i) + ": " + str(table_ws.cell(i, 1))) @@ -624,7 +624,7 @@ def _validate_matrix_peak_height(self, matrix_ws, expected_height, expected_bin, peak_bin = np.argmax(y_data) tolerance_value = expected_height * tolerance abs_difference = abs(expected_height - peak_height) - self.assertTrue(abs_difference <= abs(tolerance_value), + self.assertLessEqual(abs_difference, abs(tolerance_value), msg="abs({:.6f} - {:.6f}) > {:.6f}".format(expected_height,peak_height, tolerance_value)) self.assertTrue(abs(peak_bin - expected_bin) <= bin_tolerance, msg="abs({:.6f} - {:.6f}) > {:.6f}".format(peak_bin, expected_bin, bin_tolerance)) diff --git a/qt/python/mantidqt/plotting/test/test_functions.py b/qt/python/mantidqt/plotting/test/test_functions.py index fae64c0207d4ac9248f44de802a995eada56bb09..0e73512a118612184b3fd408a9b4f40b3d692cdc 100644 --- a/qt/python/mantidqt/plotting/test/test_functions.py +++ b/qt/python/mantidqt/plotting/test/test_functions.py @@ -68,7 +68,7 @@ class FunctionsTest(TestCase): plt.pcolormesh(np.arange(9.).reshape(3,3)) allowed, msg = can_overplot() self.assertFalse(allowed) - self.assertTrue(len(msg) > 0) + self.assertGreater(len(msg), 0) def test_current_figure_or_none_returns_none_if_no_figures_exist(self): self.assertEqual(current_figure_or_none(), None) diff --git a/qt/python/mantidqt/widgets/test/test_jupyterconsole.py b/qt/python/mantidqt/widgets/test/test_jupyterconsole.py index 75982c450b109d03b1353006e1d0530d81d7f271..06d7c7ed98b6c2015da5aa326a0417110317e48d 100644 --- a/qt/python/mantidqt/widgets/test/test_jupyterconsole.py +++ b/qt/python/mantidqt/widgets/test/test_jupyterconsole.py @@ -27,7 +27,7 @@ class InProcessJupyterConsoleTest(GuiTest): widget = InProcessJupyterConsole() self.assertTrue(hasattr(widget, "kernel_manager")) self.assertTrue(hasattr(widget, "kernel_client")) - self.assertTrue(len(widget.banner) > 0) + self.assertGreater(len(widget.banner), 0) self._pre_delete_console_cleanup(widget) del widget diff --git a/scripts/test/ConvertToWavelengthTest.py b/scripts/test/ConvertToWavelengthTest.py index 8229cc64c063f62f743b01cc946df7524f683b3a..e88e9b306d9d061cd394df2285c78a8f9b62cb41 100644 --- a/scripts/test/ConvertToWavelengthTest.py +++ b/scripts/test/ConvertToWavelengthTest.py @@ -136,8 +136,8 @@ class ConvertToWavelengthTest(unittest.TestCase): self.assertEqual("Wavelength", monitor_ws.getAxis(0).getUnit().unitID()) x_min, x_max = ConvertToWavelengthTest.cropped_x_range(detector_ws, 0) - self.assertTrue(x_min >= 0.0) - self.assertTrue(x_max <= 10.0) + self.assertGreaterEqual(x_min, 0.0) + self.assertLessEqual(x_max, 10.0) if __name__ == '__main__': unittest.main() diff --git a/scripts/test/CrystalFieldMultiSiteTest.py b/scripts/test/CrystalFieldMultiSiteTest.py index 2c2a583ee700d0f04f00508fd0638e9af8c2921c..9411a5a0907d09e790981d4eded174b5736cb47e 100644 --- a/scripts/test/CrystalFieldMultiSiteTest.py +++ b/scripts/test/CrystalFieldMultiSiteTest.py @@ -252,8 +252,8 @@ class CrystalFieldMultiSiteTests(unittest.TestCase): fit = CrystalFieldFit(Model=cf, InputWorkspace=ws, MaxIterations=10) fit.fit() - self.assertTrue(cf.chi2 > 0.0) - self.assertTrue(cf.chi2 < chi2) + self.assertGreater(cf.chi2, 0.0) + self.assertLess(cf.chi2, chi2) def test_fit_multi_ion_and_spectra(self): from CrystalField.fitting import makeWorkspace @@ -287,8 +287,8 @@ class CrystalFieldMultiSiteTests(unittest.TestCase): fit = CrystalFieldFit(Model=cf, InputWorkspace=[ws1, ws2], MaxIterations=10) fit.fit() - self.assertTrue(cf.chi2 > 0.0) - self.assertTrue(cf.chi2 < chi2) + self.assertGreater(cf.chi2, 0.0) + self.assertLess(cf.chi2, chi2) def test_set_background(self): cf = CrystalFieldMultiSite(Ions='Ce', Symmetries='C2v', Temperatures=[20], FWHM=[1.0], Background='name=LinearBackground,A0=1') diff --git a/scripts/test/CrystalFieldTest.py b/scripts/test/CrystalFieldTest.py index 9d4e6ad9b70e6d8b677dfd6649bc07e0305ba42c..ca385e1d5b66f682a2d5c1f0a35f637f43f4ae09 100644 --- a/scripts/test/CrystalFieldTest.py +++ b/scripts/test/CrystalFieldTest.py @@ -683,7 +683,7 @@ class CrystalFieldFitTest(unittest.TestCase): fit = CrystalFieldFit(cf, InputWorkspace=[ws0, ws1], MaxIterations=10) fit.fit() - self.assertTrue(cf.chi2 < chi2) + self.assertLess(cf.chi2, chi2) # Fit outputs are different on different platforms. # The following assertions are not for testing but to illustrate @@ -802,7 +802,7 @@ class CrystalFieldFitTest(unittest.TestCase): fit = CrystalFieldFit(cf, InputWorkspace=[ws0, ws1]) fit.fit() - self.assertTrue(cf.chi2 < chi2) + self.assertLess(cf.chi2, chi2) # Fit outputs are different on different platforms. # The following assertions are not for testing but to illustrate @@ -1281,8 +1281,8 @@ class CrystalFieldFitTest(unittest.TestCase): fit.monte_carlo(NSamples=100, Constraints='20<f1.PeakCentre<45,20<f2.PeakCentre<45', Seed=123) # Run fit fit.fit() - self.assertTrue(cf.chi2 > 0.0) - self.assertTrue(cf.chi2 < 100.0) + self.assertGreater(cf.chi2, 0.0) + self.assertLess(cf.chi2, 100.0) def test_monte_carlo_multi_spectrum(self): from CrystalField.fitting import makeWorkspace @@ -1306,8 +1306,8 @@ class CrystalFieldFitTest(unittest.TestCase): fit.monte_carlo(NSamples=100, Constraints='20<f0.f1.PeakCentre<45,20<f0.f2.PeakCentre<45', Seed=123) # Run fit fit.fit() - self.assertTrue(cf.chi2 > 0.0) - self.assertTrue(cf.chi2 < 200.0) + self.assertGreater(cf.chi2, 0.0) + self.assertLess(cf.chi2, 200.0) def test_normalisation(self): from CrystalField.normalisation import split2range @@ -1346,7 +1346,7 @@ class CrystalFieldFitTest(unittest.TestCase): Type='Cross Entropy', NSamples=10, Seed=123) # Run fit fit.fit() - self.assertTrue(cf.chi2 < 100.0) + self.assertLess(cf.chi2, 100.0) def test_estimate_parameters_multiple_results(self): from CrystalField.fitting import makeWorkspace @@ -1368,9 +1368,9 @@ class CrystalFieldFitTest(unittest.TestCase): fit = CrystalFieldFit(cf, InputWorkspace=ws) fit.estimate_parameters(50, ['B22', 'B40', 'B42', 'B44'], constraints='20<f1.PeakCentre<45,20<f2.PeakCentre<45', NSamples=100, Seed=123) - self.assertTrue(fit.get_number_estimates() > 1) + self.assertGreater(fit.get_number_estimates(), 1) fit.fit() - self.assertTrue(cf.chi2 < 100.0) + self.assertLess(cf.chi2, 100.0) def test_intensity_scaling_single_spectrum(self): from CrystalField import CrystalField, CrystalFieldFit, Background, Function diff --git a/scripts/test/DirectEnergyConversionTest.py b/scripts/test/DirectEnergyConversionTest.py index a2eb02a199e1de01dc64d1b42dcbb48e38cc8042..a01600b368bfc69de89aa9fba92a7f0ade3249e6 100644 --- a/scripts/test/DirectEnergyConversionTest.py +++ b/scripts/test/DirectEnergyConversionTest.py @@ -58,7 +58,7 @@ class DirectEnergyConversionTest(unittest.TestCase): def verify_present_and_delete(file_list): for file in file_list: file = FileFinder.getFullPath(file) - self.assertTrue(len(file)>0) + self.assertGreater(len(file), 0) os.remove(file) clean_up(files) @@ -342,9 +342,9 @@ class DirectEnergyConversionTest(unittest.TestCase): xMax = max(x) - self.assertTrue(tof_range[0]>xMin) + self.assertGreater(tof_range[0], xMin) #self.assertAlmostEqual(tof_range[1],dt) - self.assertTrue(tof_range[2]<xMax) + self.assertLess(tof_range[2], xMax) # check another working mode red.prop_man.multirep_tof_specta_list = 4 @@ -353,12 +353,12 @@ class DirectEnergyConversionTest(unittest.TestCase): tof_range1 = red.find_tof_range_for_multirep(run_tof) - self.assertTrue(tof_range1[0]>xMin) - self.assertTrue(tof_range1[2]<xMax) + self.assertGreater(tof_range1[0], xMin) + self.assertLess(tof_range1[2], xMax) - self.assertTrue(tof_range1[2]<tof_range[2]) - self.assertTrue(tof_range1[0]<tof_range[0]) - self.assertTrue(tof_range1[1]<tof_range[1]) + self.assertLess(tof_range1[2], tof_range[2]) + self.assertLess(tof_range1[0], tof_range[0]) + self.assertLess(tof_range1[1], tof_range[1]) def test_multirep_mode(self): # create test workspace diff --git a/scripts/test/PyChopTest.py b/scripts/test/PyChopTest.py index 7ec38023a5046273446091179aa8906d7f0ece5d..42e55f2797a2e5e915a238ce39c8b6151cfa8955 100644 --- a/scripts/test/PyChopTest.py +++ b/scripts/test/PyChopTest.py @@ -31,13 +31,13 @@ class PyChop2Tests(unittest.TestCase): res.append(rr) flux.append(ff) # Checks that the flux should be highest for MERLIN, MARI and MAPS in that order - self.assertTrue(flux[2] > flux[1]) + self.assertGreater(flux[2], flux[1]) # Note that MAPS has been upgraded so now should have higher flux than MARI. - self.assertTrue(flux[0] > flux[1]) + self.assertGreater(flux[0], flux[1]) # Checks that the resolution should be best for MARI, MAPS, and MERLIN in that order # actually MAPS and MARI resolutions are very close - self.assertTrue(res[1][0] < res[0][0]) - self.assertTrue(res[0][0] < res[2][0]) + self.assertLess(res[1][0], res[0][0]) + self.assertLess(res[0][0], res[2][0]) # Now tests the standalone function for inc, instname in enumerate(instnames): rr, ff = PyChop2.calculate(instname, 's', 200, 18, 0) @@ -62,11 +62,11 @@ class PyChop2Tests(unittest.TestCase): res.append(rr) flux.append(ff) # Checks that the flux should be highest for 'High flux', then 'Intermediate', 'High resolution' - self.assertTrue(flux[0] > flux[1]) - self.assertTrue(flux[1] >= flux[2]) + self.assertGreater(flux[0], flux[1]) + self.assertGreaterEqual(flux[1], flux[2]) # Checks that the resolution should be best for 'High resolution', then 'Intermediate', 'High flux' - self.assertTrue(res[2][0] <= res[1][0]) - self.assertTrue(res[1][0] <= res[0][0]) + self.assertLessEqual(res[2][0], res[1][0]) + self.assertLessEqual(res[1][0], res[0][0]) # Now tests the standalone function for inc, variant in enumerate(variants): rr, ff = PyChop2.calculate('LET', variant, 200, 18, 0) diff --git a/scripts/test/RunDescriptorTest.py b/scripts/test/RunDescriptorTest.py index 8e9a67c305c27a0ff63e64770136aec2ef65344d..224b55fec8bf9a40be671effadc6a0166d4ef30b 100644 --- a/scripts/test/RunDescriptorTest.py +++ b/scripts/test/RunDescriptorTest.py @@ -94,7 +94,7 @@ class RunDescriptorTest(unittest.TestCase): ok,file=PropertyManager.sample_run.find_file(propman) self.assertTrue(ok) - self.assertTrue(len(file)>0) + self.assertGreater(len(file), 0) ext = PropertyManager.sample_run.get_fext() self.assertEqual(ext,'.raw') @@ -225,7 +225,7 @@ class RunDescriptorTest(unittest.TestCase): PropertyManager.sample_run.synchronize_ws(ws1) ws1 = PropertyManager.sample_run.get_workspace() - self.assertTrue(str.find(ws1.name(),'_modified')>0) + self.assertGreater(str.find(ws1.name(),'_modified'), 0) propman.sample_run = ws1 self.assertEqual(ws1.name(),PropertyManager.sample_run._ws_name) diff --git a/scripts/test/SANS/algorithm_detail/merge_reductions_test.py b/scripts/test/SANS/algorithm_detail/merge_reductions_test.py index 7e6c81f0e2af4be7689d8fe6845987dbf5a73fb2..7517da03e0ae72bcf6696f10fc38e70cce48c8d4 100644 --- a/scripts/test/SANS/algorithm_detail/merge_reductions_test.py +++ b/scripts/test/SANS/algorithm_detail/merge_reductions_test.py @@ -200,8 +200,8 @@ class MergeReductionsTest(unittest.TestCase): shift = result.shift self.assertNotEqual(scale, scale_input) - self.assertTrue(abs(scale-1.0) < 1e-4) - self.assertTrue(abs(shift-shift_input) < 1e-4) + self.assertLess(abs(scale-1.0), 1e-4) + self.assertLess(abs(shift-shift_input), 1e-4) if __name__ == '__main__': diff --git a/scripts/test/SANS/gui_logic/add_runs_presenter_test.py b/scripts/test/SANS/gui_logic/add_runs_presenter_test.py index 0e0114f7c238e1fd3ef675afc9ea98e91ff2360c..144d1f73ae2c59f0eb42ca658fb41d934b8007b7 100644 --- a/scripts/test/SANS/gui_logic/add_runs_presenter_test.py +++ b/scripts/test/SANS/gui_logic/add_runs_presenter_test.py @@ -296,9 +296,7 @@ class BaseFileNameTest(SelectionMockingTestCase): self._on_model_updated(new_selection) def _base_file_name_arg(self, run_summation_mock): - first_call = 0 - print(run_summation_mock.call_args) - return run_summation_mock.call_args[first_call][2] + return run_summation_mock.call_args[0][2] def _retrieve_generated_name_for(self, run_paths): run_summation = mock.Mock()