From b30fee61205df31bab121a4a80e06b8d7a903aa2 Mon Sep 17 00:00:00 2001 From: Silke Schomann Date: Wed, 31 Jan 2024 09:53:14 +0000 Subject: [PATCH] Update tests with True flag for ADS.clear() --- tests/cut_algorithm_test.py | 5 +---- tests/cut_functions_test.py | 5 +---- tests/cut_normalisation_test.py | 5 +---- tests/projection_calculator_test.py | 5 +---- tests/rebose_algorithm_test.py | 5 +---- tests/slice_algorithm_test.py | 5 +---- tests/slice_functions_test.py | 5 +---- tests/workspace_algorithms_test.py | 5 +---- 8 files changed, 8 insertions(+), 32 deletions(-) diff --git a/tests/cut_algorithm_test.py b/tests/cut_algorithm_test.py index 59eae195..225c864a 100644 --- a/tests/cut_algorithm_test.py +++ b/tests/cut_algorithm_test.py @@ -1,7 +1,6 @@ import numpy as np from unittest import TestCase from unittest.mock import MagicMock, patch -import warnings from mantid.api import AnalysisDataService from mantid.dataobjects import MDHistoWorkspace @@ -28,9 +27,7 @@ def setUp(self): self.theta_axis = Axis("2Theta", -10, 15, 1) def tearDown(self) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) def xtest_that_compute_cut_returns_a_result_with_the_expected_size_for_normalized_psd_rebin_data(self): normalized = True diff --git a/tests/cut_functions_test.py b/tests/cut_functions_test.py index 5fb46bd6..f693abb2 100644 --- a/tests/cut_functions_test.py +++ b/tests/cut_functions_test.py @@ -2,7 +2,6 @@ from mock import patch from unittest import TestCase -import warnings from mantid.api import AlgorithmFactory, AnalysisDataService from mantid.simpleapi import AddSampleLog, _create_algorithm_function @@ -42,9 +41,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) def test_that_output_workspace_name_returns_the_expected_result(self): self.assertEqual(output_workspace_name(self.workspace_name, self.integration_start, self.integration_end), diff --git a/tests/cut_normalisation_test.py b/tests/cut_normalisation_test.py index acba5448..2c7377c8 100644 --- a/tests/cut_normalisation_test.py +++ b/tests/cut_normalisation_test.py @@ -1,6 +1,5 @@ import numpy as np from unittest import TestCase -import warnings from mantid.api import AnalysisDataService @@ -15,9 +14,7 @@ def setUp(self): self.md_histo_ws = create_md_histo_workspace(2, "md_histo_ws") def tearDown(self) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) def test_that_normalize_workspace_fails_for_a_non_IMDHistoWorkspace(self): try: diff --git a/tests/projection_calculator_test.py b/tests/projection_calculator_test.py index c37ba503..4157dc7b 100644 --- a/tests/projection_calculator_test.py +++ b/tests/projection_calculator_test.py @@ -1,5 +1,4 @@ from unittest import TestCase -import warnings from mantid.api import AnalysisDataService @@ -21,9 +20,7 @@ def setUp(self): self.projection_calculator = MantidProjectionCalculator() def tearDown(self) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) def test_available_axes(self): self.assertEqual(self.projection_calculator.available_axes(), ['|Q|', '2Theta', 'DeltaE']) diff --git a/tests/rebose_algorithm_test.py b/tests/rebose_algorithm_test.py index cb32c60f..eb6a068a 100644 --- a/tests/rebose_algorithm_test.py +++ b/tests/rebose_algorithm_test.py @@ -1,5 +1,4 @@ import unittest -import warnings from mantid.api import AnalysisDataService from tests.testhelpers.workspace_creator import create_workspace @@ -14,9 +13,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) def test_rebose_algorithm(self): results = Rebose(self.test_workspace) diff --git a/tests/slice_algorithm_test.py b/tests/slice_algorithm_test.py index af4c77dc..57c01e30 100644 --- a/tests/slice_algorithm_test.py +++ b/tests/slice_algorithm_test.py @@ -3,7 +3,6 @@ from mock import patch, MagicMock, call, ANY import numpy as np import unittest -import warnings from mantid.simpleapi import AddSampleLog, AnalysisDataService from mantid.kernel import PropertyManager @@ -56,9 +55,7 @@ def setUpClass(cls): def tearDown(self) -> None: self.test_objects = None # reset test objects - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) @staticmethod def _create_tst_objects(sim_scattering_data, x_dict, y_dict, norm_to_one=False, PSD=False, e_mode='Direct'): diff --git a/tests/slice_functions_test.py b/tests/slice_functions_test.py index 05539f8e..ff0483d3 100644 --- a/tests/slice_functions_test.py +++ b/tests/slice_functions_test.py @@ -3,7 +3,6 @@ from mock import patch, MagicMock import numpy as np import unittest -import warnings from mantid.api import AlgorithmFactory from mantid.simpleapi import AddSampleLog, _create_algorithm_function, AnalysisDataService @@ -35,9 +34,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) @patch('mslice.models.slice.slice_functions.mantid_algorithms') def test_slice(self, alg_mock): diff --git a/tests/workspace_algorithms_test.py b/tests/workspace_algorithms_test.py index 5ae5ea78..33545f3e 100644 --- a/tests/workspace_algorithms_test.py +++ b/tests/workspace_algorithms_test.py @@ -1,7 +1,6 @@ from __future__ import (absolute_import, division, print_function) import unittest -import warnings from mslice.models.axis import Axis from mslice.models.workspacemanager.workspace_algorithms import (process_limits, process_limits_event, scale_workspaces, @@ -45,9 +44,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - AnalysisDataService.clear() + AnalysisDataService.clear(True) def test_process_limits_does_not_fail_for_direct_data(self): process_limits(self.direct_workspace)