From 44eb03aa6df1a33b905193f5748fabf20767369b Mon Sep 17 00:00:00 2001 From: Tom Titcombe <t.j.titcombe@gmail.com> Date: Fri, 31 May 2019 14:02:48 +0100 Subject: [PATCH] Change assertTrue(a > b) to assertGreater(a, b) Change assertTrue(a >= b) to assertGreaterEqual(a, b) Change assertTrue(a < b) to assertLess(a, b) Change assertTrue(a <= b) to assertLessEqual(a, b) --- .../test/python/mantid/SimpleAPITest.py | 4 +-- .../api/DeprecatedAlgorithmCheckerTest.py | 2 +- .../test/python/mantid/api/FileFinderTest.py | 6 ++-- .../python/mantid/api/FunctionFactoryTest.py | 2 +- .../test/python/mantid/api/MDGeometryTest.py | 2 +- .../python/mantid/api/MatrixWorkspaceTest.py | 6 ++-- .../python/mantid/api/SpectrumInfoTest.py | 2 +- .../mantid/geometry/ComponentInfoTest.py | 2 +- .../mantid/geometry/DetectorInfoTest.py | 4 +-- .../python/mantid/kernel/ConfigServiceTest.py | 2 +- .../python/mantid/kernel/FacilityInfoTest.py | 2 +- .../mantid/kernel/PropertyWithValueTest.py | 2 +- .../python/mantid/kernel/PythonPluginsTest.py | 2 +- .../python/mantid/kernel/UnitFactoryTest.py | 2 +- .../algorithms/CropWorkspaceForMDNormTest.py | 4 +-- .../algorithms/ExportExperimentLogTest.py | 30 +++++++++---------- .../plugins/algorithms/FitGaussianTest.py | 4 +-- .../plugins/algorithms/LRPeakSelectionTest.py | 12 ++++---- .../algorithms/NormaliseSpectraTest.py | 4 +-- .../algorithms/SANSWideAngleCorrectionTest.py | 4 +-- .../plugins/algorithms/SaveNexusPDTest.py | 2 +- .../plugins/algorithms/StringToPngTest.py | 2 +- .../plugins/algorithms/SymmetriseTest.py | 2 +- .../algorithms/TOFTOFCropWorkspaceTest.py | 4 +-- .../ApplyPaalmanPingsCorrectionTest.py | 2 +- .../WorkflowAlgorithms/MolDynTest.py | 2 +- .../WorkflowAlgorithms/SavePlot1DTest.py | 4 +-- .../sans/SANSCalculateTransmissionTest.py | 2 +- .../sans/SANSNormalizeToMonitorTest.py | 2 +- .../sans/SANSSliceEventTest.py | 4 +-- .../tests/analysis/HFIRTestsAPIv2.py | 14 ++++----- .../analysis/ILLPowderD2BEfficiencyTest.py | 4 +-- .../tests/analysis/POLDILoadRunsTest.py | 4 +-- .../tests/analysis/POLDIMergeTest.py | 2 +- .../analysis/QENSGlobalFitTeixeiraWaterSQE.py | 6 ++-- .../tests/analysis/ReflectometryISIS.py | 2 +- .../tests/analysis/SANSSaveTest.py | 6 ++-- .../tests/analysis/VesuvioCommandsTest.py | 2 +- .../tests/analysis/VesuvioCorrectionsTest.py | 4 +-- .../mantidqt/plotting/test/test_functions.py | 2 +- .../widgets/test/test_jupyterconsole.py | 2 +- scripts/test/ConvertToWavelengthTest.py | 4 +-- scripts/test/CrystalFieldMultiSiteTest.py | 8 ++--- scripts/test/CrystalFieldTest.py | 18 +++++------ scripts/test/DirectEnergyConversionTest.py | 16 +++++----- scripts/test/PyChopTest.py | 16 +++++----- scripts/test/RunDescriptorTest.py | 4 +-- .../algorithm_detail/merge_reductions_test.py | 4 +-- .../SANS/gui_logic/add_runs_presenter_test.py | 4 +-- 49 files changed, 122 insertions(+), 124 deletions(-) diff --git a/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py b/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py index a046c1c697e..bc7ae01dde8 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 90e4231ec35..0df12e8bb1d 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 d7fe49d661f..8552373c9a5 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 30d5f4abf23..cae32f38b10 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 de65b218dd1..24bab20410f 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 39b0f622a26..7b0c4e42c8b 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 694a9a84d27..42ac671e47e 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 6ac48ff2ca9..2ba71f65673 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 53a95af1d85..1315198f3d2 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 05f1c0f512b..ac7b8a85edc 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 e7241af926f..cfd5fbf621c 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 3836be11ef4..243c0299d81 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 5fc1ea953af..2b18b396401 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 13c7d0b74e4..b7bdc7df3eb 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 0366a3417a1..82996a83865 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 52afb260606..d131323b535 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 c7e7e7c16d8..d39bed5e42e 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 917b6d9abdc..3813b958adc 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 dab8c500ab3..e3ab82f0c6e 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 3db8fa702c2..b7fe9057de6 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 e09cc01ec60..0bab9a2a6ac 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 0853ccd8ff8..4ac5ee8c85a 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 ce70e06b632..416903c6779 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 d6dfe2d65f0..d1ce03d3c31 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 3e14e6a704a..c6358478f91 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 695a18ee607..36ee2a100e8 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 96b8cb6ea0e..15981dd9a12 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 42c8de3c505..0daf5a5a11c 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 72d5d3e9852..ee04905692d 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 87c5768d0bf..9d0d7d838e0 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 60d8a67f96c..391c3600fcb 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 1a9cf9f87a4..33b45cde221 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 a1bfcd534f4..9f9c94e1113 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 1fa34155c4a..9c284dfeef8 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 45e0fa9b05f..f850e3e02ff 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 4bdde40d9b7..235f7562d10 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 c69c993b4e4..0fef0d6cc08 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 225bbf999c9..1551ec8c73e 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 85fa6944d5e..807f5c8d4aa 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 fae64c0207d..0e73512a118 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 75982c450b1..06d7c7ed98b 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 8229cc64c06..e88e9b306d9 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 2c2a583ee70..9411a5a0907 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 9d4e6ad9b70..ca385e1d5b6 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 a2eb02a199e..a01600b368b 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 7ec38023a50..42e55f2797a 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 8e9a67c305c..224b55fec8b 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 7e6c81f0e2a..7517da03e0a 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 0e0114f7c23..144d1f73ae2 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() -- GitLab