From 96174646b651f8b0437c79f3144d0eda91bb22dc Mon Sep 17 00:00:00 2001 From: Conor Finn <conor.finn@stfc.ac.uk> Date: Mon, 9 Mar 2020 16:51:28 +0000 Subject: [PATCH] RE #27722 Replace assertRaisesRegex imported from six --- .../ReflectometryILLSumForegroundTest.py | 4 +- .../test/ISISPowderAbsorptionTest.py | 6 +-- .../isis_powder/test/ISISPowderCommonTest.py | 34 ++++++++--------- .../test/ISISPowderInstrumentSettingsTest.py | 12 +++--- .../test/ISISPowderSampleDetailsTest.py | 38 +++++++++---------- .../test/ISISPowderYamlParserTest.py | 16 ++++---- .../cropping/test/test_cropping_model.py | 6 +-- 7 files changed, 55 insertions(+), 61 deletions(-) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py index a6e4976dfd2..b9248af301e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py @@ -215,7 +215,7 @@ class ReflectometryILLSumForegroundTest(unittest.TestCase): 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) - self.assertRaisesRegexp(RuntimeError, 'Some invalid Properties found', alg.execute) + self.assertRaisesRegex(RuntimeError, 'Some invalid Properties found', alg.execute) self.assertTrue(alg.isExecuted) def testNotSummedDirectForegroundRaises(self): @@ -231,7 +231,7 @@ class ReflectometryILLSumForegroundTest(unittest.TestCase): 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) - self.assertRaisesRegexp(RuntimeError, 'Some invalid Properties found', alg.execute) + self.assertRaisesRegex(RuntimeError, 'Some invalid Properties found', alg.execute) self.assertTrue(alg.isExecuted) def testReflectedBeamSumInLambdaNoRotation(self): diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py index ffb238a4a74..801887642f4 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py @@ -7,8 +7,6 @@ import mantid.simpleapi as mantid import unittest -from six import assertRaisesRegex - from isis_powder.routines import absorb_corrections, SampleDetails @@ -41,11 +39,11 @@ class ISISPowderAbsorptionTest(unittest.TestCase): modified_dict.pop(blacklisted_key) # Check that is raises an error - with assertRaisesRegex(self, KeyError, "The following key was not found in the advanced configuration"): + with self.assertRaisesRegex(KeyError, "The following key was not found in the advanced configuration"): absorb_corrections.create_vanadium_sample_details_obj(config_dict=modified_dict) # Then check the error actually has the key name in it - with assertRaisesRegex(self, KeyError, blacklisted_key): + with self.assertRaisesRegex(KeyError, blacklisted_key): absorb_corrections.create_vanadium_sample_details_obj(config_dict=modified_dict) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py index f275fbd63dc..21284c0a3e5 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py @@ -7,8 +7,6 @@ import mantid.simpleapi as mantid # Have to import Mantid to setup paths import unittest -from six import assertRaisesRegex - from isis_powder.routines import common, common_enums, SampleDetails @@ -21,12 +19,12 @@ class ISISPowderCommonTest(unittest.TestCase): dict_with_key = {correct_key_name: expected_val} # Check it correctly raises - with assertRaisesRegex(self, KeyError, "The field '" + missing_key_name + "' is required"): + with self.assertRaisesRegex(KeyError, "The field '" + missing_key_name + "' is required"): common.cal_map_dictionary_key_helper(dictionary=dict_with_key, key=missing_key_name) # Check it correctly appends the passed error message when raising appended_e_msg = "test append message" - with assertRaisesRegex(self, KeyError, appended_e_msg): + with self.assertRaisesRegex(KeyError, appended_e_msg): common.cal_map_dictionary_key_helper(dictionary=dict_with_key, key=missing_key_name, append_to_error_message=appended_e_msg) @@ -58,15 +56,15 @@ class ISISPowderCommonTest(unittest.TestCase): bank_list.append(mantid.CreateSampleWorkspace(OutputWorkspace=out_name, XMin=0, XMax=1100, BinWidth=1)) # Check a list of WS and single cropping value is detected - with assertRaisesRegex(self, ValueError, "The cropping values were not in a list or tuple type"): + with self.assertRaisesRegex(ValueError, "The cropping values were not in a list or tuple type"): common.crop_banks_using_crop_list(bank_list=bank_list, crop_values_list=1000) # Check a list of cropping values and a single workspace is detected - with assertRaisesRegex(self, RuntimeError, "Attempting to use list based cropping"): + with self.assertRaisesRegex(RuntimeError, "Attempting to use list based cropping"): common.crop_banks_using_crop_list(bank_list=bank_list[0], crop_values_list=cropping_value_list) # What about a mismatch between the number of cropping values and workspaces - with assertRaisesRegex(self, RuntimeError, "The number of TOF cropping values does not match"): + with self.assertRaisesRegex(RuntimeError, "The number of TOF cropping values does not match"): common.crop_banks_using_crop_list(bank_list=bank_list[1:], crop_values_list=cropping_value_list) # Check we can crop a single workspace from the list @@ -95,11 +93,11 @@ class ISISPowderCommonTest(unittest.TestCase): bank_list.append(mantid.CreateSampleWorkspace(OutputWorkspace=out_name, XMin=x_min, XMax=x_max, BinWidth=1)) # Check a list of WS and non list or tuple - with assertRaisesRegex(self, ValueError, "The cropping values were not in a list or tuple type"): + with self.assertRaisesRegex(ValueError, "The cropping values were not in a list or tuple type"): common.crop_banks_using_crop_list(bank_list=bank_list, crop_values_list=1000) # Check a cropping value and a single workspace is detected - with assertRaisesRegex(self, RuntimeError, "Attempting to use list based cropping"): + with self.assertRaisesRegex(RuntimeError, "Attempting to use list based cropping"): common.crop_banks_using_crop_list(bank_list=bank_list[0], crop_values_list=cropping_value) # Check we can crop a single workspace from the list @@ -206,7 +204,7 @@ class ISISPowderCommonTest(unittest.TestCase): with self.assertRaises(KeyError): common.dictionary_key_helper(dictionary=test_dictionary, key=bad_key_name) - with assertRaisesRegex(self, KeyError, e_msg): + with self.assertRaisesRegex(KeyError, e_msg): common.dictionary_key_helper(dictionary=test_dictionary, key=bad_key_name, exception_msg=e_msg) self.assertEqual(common.dictionary_key_helper(dictionary=test_dictionary, key=good_key_name), 123) @@ -310,11 +308,11 @@ class ISISPowderCommonTest(unittest.TestCase): def test_generate_run_numbers_fails(self): run_input_sting = "text-string" - with assertRaisesRegex(self, ValueError, "Could not generate run numbers from this input"): + with self.assertRaisesRegex(ValueError, "Could not generate run numbers from this input"): common.generate_run_numbers(run_number_string=run_input_sting) # Check it says what the actual string was - with assertRaisesRegex(self, ValueError, run_input_sting): + with self.assertRaisesRegex(ValueError, run_input_sting): common.generate_run_numbers(run_number_string=run_input_sting) def test_load_current_normalised_workspace(self): @@ -444,14 +442,14 @@ class ISISPowderCommonTest(unittest.TestCase): NumBanks=1, BankPixelWidth=1, XMax=10, BinWidth=1)) # What if the item passed in is not a list err_msg_not_list = "was not a list" - with assertRaisesRegex(self, RuntimeError, err_msg_not_list): + with self.assertRaisesRegex(RuntimeError, err_msg_not_list): common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=None) - with assertRaisesRegex(self, RuntimeError, err_msg_not_list): + with self.assertRaisesRegex(RuntimeError, err_msg_not_list): common.rebin_workspace_list(workspace_list=None, bin_width_list=[]) # What about if the lists aren't the same length - with assertRaisesRegex(self, ValueError, "does not match the number of banks"): + with self.assertRaisesRegex(ValueError, "does not match the number of banks"): incorrect_number_bin_widths = [1] * (number_of_ws - 1) common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=incorrect_number_bin_widths) @@ -480,10 +478,10 @@ class ISISPowderCommonTest(unittest.TestCase): # Are the lengths checked incorrect_length = [1] * (number_of_ws - 1) - with assertRaisesRegex(self, ValueError, "The number of starting bin values"): + with self.assertRaisesRegex(ValueError, "The number of starting bin values"): common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=ws_bin_widths, start_x_list=incorrect_length, end_x_list=end_x_list) - with assertRaisesRegex(self, ValueError, "The number of ending bin values"): + with self.assertRaisesRegex(ValueError, "The number of ending bin values"): common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=ws_bin_widths, start_x_list=start_x_list, end_x_list=incorrect_length) @@ -588,7 +586,7 @@ class ISISPowderCommonTest(unittest.TestCase): ws_file_name = "100" # Load POL100 # This should throw as the TOF ranges do not match - with assertRaisesRegex(self, ValueError, "specified for this file do not have matching binning. Do the "): + with self.assertRaisesRegex(ValueError, "specified for this file do not have matching binning. Do the "): common.subtract_summed_runs(ws_to_correct=sample_ws, instrument=ISISPowderMockInst(), empty_sample_ws_string=ws_file_name) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py index 929cacec3a3..727cdc13bc9 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py @@ -7,7 +7,7 @@ import unittest import warnings -from six import assertRaisesRegex, assertRegex +from six import assertRegex from isis_powder.routines import instrument_settings, param_map_entry @@ -18,7 +18,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry]) - with assertRaisesRegex(self, AttributeError, "is required but was not set or passed"): + with self.assertRaisesRegex(AttributeError, "is required but was not set or passed"): foo = inst_settings_obj.script_facing_name del foo @@ -28,7 +28,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry]) # Check it still prints the acceptable values when it fails - with assertRaisesRegex(self, AttributeError, "A BAR"): + with self.assertRaisesRegex(AttributeError, "A BAR"): foo = inst_settings_obj.script_facing_name del foo @@ -37,7 +37,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry]) - with assertRaisesRegex(self, AttributeError, "Please contact the development team"): + with self.assertRaisesRegex(AttributeError, "Please contact the development team"): foo = inst_settings_obj.not_known del foo @@ -141,7 +141,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): # First test we cannot set it to a different value incorrect_value_dict = {"user_facing_name": "wrong"} - with assertRaisesRegex(self, ValueError, "The user specified value: 'wrong' is unknown"): + with self.assertRaisesRegex(ValueError, "The user specified value: 'wrong' is unknown"): instrument_settings.InstrumentSettings(param_map=[param_entry], adv_conf_dict=incorrect_value_dict) @@ -157,7 +157,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): def test_param_map_rejects_enum_missing_friendly_name(self): # Check that is the friendly name is not set it is correctly detected - with assertRaisesRegex(self, RuntimeError, + with self.assertRaisesRegex(RuntimeError, "'enum_friendly_name' was not set. Please contact development team."): param_map_entry.ParamMapEntry(ext_name="user_facing_name", int_name="script_facing_name", enum_class=BadSampleEnum) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py index 671b3edd903..3c89e845694 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py @@ -11,7 +11,7 @@ import unittest from isis_powder.routines import sample_details -from six import assertRaisesRegex, assertRegex +from six import assertRegex class ISISPowderSampleDetailsTest(unittest.TestCase): @@ -59,34 +59,34 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): char_input_value = 'a' # Check it handles empty input - with assertRaisesRegex(self, ValueError, "Could not convert the height to a number"): + with self.assertRaisesRegex(ValueError, "Could not convert the height to a number"): sample_details.SampleDetails(height=empty_input_value, radius=good_input, center=good_center_input, shape="cylinder") # Does it handle bad input and tell us what we put in - with assertRaisesRegex(self, ValueError, ".*to a number. The input was: '" + char_input_value + "'"): + with self.assertRaisesRegex(ValueError, ".*to a number. The input was: '" + char_input_value + "'"): sample_details.SampleDetails(height=char_input_value, radius=good_input, center=good_center_input, shape="cylinder") # Does it indicate which field was incorrect - with assertRaisesRegex(self, ValueError, "radius"): + with self.assertRaisesRegex(ValueError, "radius"): sample_details.SampleDetails(height=good_input, radius=char_input_value, center=good_center_input, shape="cylinder") # Can it handle bad center values - with assertRaisesRegex(self, ValueError, "center"): + with self.assertRaisesRegex(ValueError, "center"): sample_details.SampleDetails(height=good_input, radius=good_input, center=["", 2, 3], shape="cylinder") # Does it throw if were not using a list for the input - with assertRaisesRegex(self, ValueError, "must be specified as a list of X, Y, Z"): + with self.assertRaisesRegex(ValueError, "must be specified as a list of X, Y, Z"): sample_details.SampleDetails(height=good_input, radius=good_input, center=1, shape="cylinder") # Does it throw if we are using a list of incorrect length (e.g. not 3D) - with assertRaisesRegex(self, ValueError, "must have three values corresponding to"): + with self.assertRaisesRegex(ValueError, "must have three values corresponding to"): sample_details.SampleDetails(height=good_input, radius=good_input, center=[], shape="cylinder") - with assertRaisesRegex(self, ValueError, "must have three values corresponding to"): + with self.assertRaisesRegex(ValueError, "must have three values corresponding to"): sample_details.SampleDetails(height=good_input, radius=good_input, center=[1, 2], shape="cylinder") - with assertRaisesRegex(self, ValueError, "must have three values corresponding to"): + with self.assertRaisesRegex(ValueError, "must have three values corresponding to"): sample_details.SampleDetails(height=good_input, radius=good_input, center=[1, 2, 3, 4], shape="cylinder") def test_constructor_with_impossible_val(self): @@ -98,22 +98,22 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): negative_string = "-1" # Check it handles zero - with assertRaisesRegex(self, ValueError, "The value set for height was: 0"): + with self.assertRaisesRegex(ValueError, "The value set for height was: 0"): sample_details.SampleDetails(height=zero_value, radius=good_input, center=good_center_input, shape="cylinder") # Very small negative - with assertRaisesRegex(self, ValueError, "which is impossible for a physical object"): + with self.assertRaisesRegex(ValueError, "which is impossible for a physical object"): sample_details.SampleDetails(height=good_input, radius=negative_value, center=good_center_input, shape="cylinder") # Integer negative - with assertRaisesRegex(self, ValueError, "The value set for height was: -1"): + with self.assertRaisesRegex(ValueError, "The value set for height was: -1"): sample_details.SampleDetails(height=negative_int, radius=good_input, center=good_center_input, shape="cylinder") # String negative - with assertRaisesRegex(self, ValueError, "The value set for radius was: -1"): + with self.assertRaisesRegex(ValueError, "The value set for radius was: -1"): sample_details.SampleDetails(height=good_input, radius=negative_string, center=good_center_input, shape="cylinder") @@ -125,7 +125,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertIsNotNone(sample_details_obj.material_object) # Check that the material is now immutable - with assertRaisesRegex(self, RuntimeError, "The material has already been set to the above details"): + with self.assertRaisesRegex(RuntimeError, "The material has already been set to the above details"): sample_details_obj.set_material(chemical_formula='V') # Check resetting it works @@ -142,7 +142,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertIsNone(sample_details_obj.material_object) # Check we cannot set a material property without setting the underlying material - with assertRaisesRegex(self, RuntimeError, "The material has not been set"): + with self.assertRaisesRegex(RuntimeError, "The material has not been set"): sample_details_obj.set_material_properties(absorption_cross_section=1.0, scattering_cross_section=2.0) # Check that with a material object we are allowed to set material properties @@ -178,7 +178,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertEqual(material_obj_number_density.number_density, number_density_sample) # Check that it raises an error if we have a non-elemental formula without number density - with assertRaisesRegex(self, ValueError, "A number density formula must be set on a chemical formula"): + with self.assertRaisesRegex(ValueError, "A number density formula must be set on a chemical formula"): sample_details._Material(chemical_formula=chemical_formula_complex) # Check it constructs if it is given the number density too @@ -195,14 +195,14 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): good_scattering = 2.0 material_obj = sample_details._Material(chemical_formula='V') - with assertRaisesRegex(self, ValueError, "absorption_cross_section was: -1 which is impossible for a physical " + with self.assertRaisesRegex(ValueError, "absorption_cross_section was: -1 which is impossible for a physical " "object"): material_obj.set_material_properties(abs_cross_sect=bad_absorb, scattering_cross_sect=good_scattering) # Check the immutability flag has not been set on a failure self.assertFalse(material_obj._is_material_props_set) - with assertRaisesRegex(self, ValueError, "scattering_cross_section was: 0"): + with self.assertRaisesRegex(ValueError, "scattering_cross_section was: 0"): material_obj.set_material_properties(abs_cross_sect=good_absorb, scattering_cross_sect=bad_scattering) # Check nothing has been set yet @@ -216,7 +216,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertEqual(material_obj.scattering_cross_section, float(good_scattering)) # Check we cannot set it twice and fields do not change - with assertRaisesRegex(self, RuntimeError, "The material properties have already been set"): + with self.assertRaisesRegex(RuntimeError, "The material properties have already been set"): material_obj.set_material_properties(abs_cross_sect=999, scattering_cross_sect=999) self.assertEqual(material_obj.absorption_cross_section, float(good_absorb)) self.assertEqual(material_obj.scattering_cross_section, float(good_scattering)) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py index 5f160ffa9ba..8fa884689f9 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py @@ -8,8 +8,6 @@ import tempfile import os import unittest import warnings -from six import assertRaisesRegex - from isis_powder.routines import yaml_parser @@ -77,7 +75,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): self.fail("File exists after deleting cannot continue this test") # Check the error message is there - with assertRaisesRegex(self, ValueError, "Config file not found at path"): + with self.assertRaisesRegex(ValueError, "Config file not found at path"): yaml_parser.get_run_dictionary(run_number_string="1", file_path=file_path) def test_is_run_range_unbounded(self): @@ -103,7 +101,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_path = file_handle.name file_handle.close() - with assertRaisesRegex(self, ValueError, "YAML files appears to be empty at"): + with self.assertRaisesRegex(ValueError, "YAML files appears to be empty at"): yaml_parser.get_run_dictionary(run_number_string=1, file_path=file_path) def test_run_number_not_found_gives_sane_err(self): @@ -118,15 +116,15 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_handle.close() # Test a value in the middle of 1-10 - with assertRaisesRegex(self, ValueError, "Run number 5 not recognised in cycle mapping file"): + with self.assertRaisesRegex(ValueError, "Run number 5 not recognised in cycle mapping file"): yaml_parser.get_run_dictionary(run_number_string="5", file_path=file_path) # Check on edge of invalid numbers - with assertRaisesRegex(self, ValueError, "Run number 9 not recognised in cycle mapping file"): + with self.assertRaisesRegex(ValueError, "Run number 9 not recognised in cycle mapping file"): yaml_parser.get_run_dictionary(run_number_string=9, file_path=file_path) # What about a range of numbers - with assertRaisesRegex(self, ValueError, "Run number 2 not recognised in cycle mapping file"): + with self.assertRaisesRegex(ValueError, "Run number 2 not recognised in cycle mapping file"): yaml_parser.get_run_dictionary(run_number_string="2-8", file_path=file_path) # Check valid number still works @@ -141,7 +139,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_path = file_handle.name file_handle.close() - with assertRaisesRegex(self, ValueError, "Seen multiple unbounded keys in mapping file"): + with self.assertRaisesRegex(ValueError, "Seen multiple unbounded keys in mapping file"): yaml_parser.get_run_dictionary(run_number_string="11", file_path=file_path) def test_yaml_sanity_detects_val_larger_than_unbound(self): @@ -152,7 +150,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_path = file_handle.name file_handle.close() - with assertRaisesRegex(self, ValueError, "Found a run range in calibration mapping overlaps an unbounded run " + with self.assertRaisesRegex(ValueError, "Found a run range in calibration mapping overlaps an unbounded run " "range"): yaml_parser.get_run_dictionary(run_number_string="32", file_path=file_path) diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py index 5abba91be69..75da21c3f47 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py @@ -45,9 +45,9 @@ class CroppingModelTest(unittest.TestCase): self.assertEqual(self.model._clean_spectrum_numbers("2-1, 76-5, 3"), "1-2,5-76,3") def test_clean_spectrum_numbers_equal_range(self): - self.assertRaisesRegexp(ValueError, - "Ranges cannot contain the same value twice. Invalid Range:*", - self.model._clean_spectrum_numbers, "1-1, 76-76, 3") + self.assertRaisesRegex(ValueError, + "Ranges cannot contain the same value twice. Invalid Range:*", + self.model._clean_spectrum_numbers, "1-1, 76-76, 3") def test_validate_and_clean_with_valid_input(self): self.assertEqual(self.model.validate_and_clean_spectrum_numbers("1-6, 7-23, 46, 1"), -- GitLab