From eda3a4ba5e8c6af316ab5aeb515ed29e518e7022 Mon Sep 17 00:00:00 2001 From: Peter Meisrimel Date: Wed, 2 Oct 2024 16:21:29 +0200 Subject: [PATCH] Cleanup --- tests/test_fmi_master.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/test_fmi_master.py b/tests/test_fmi_master.py index ea18f579..6b65aee3 100644 --- a/tests/test_fmi_master.py +++ b/tests/test_fmi_master.py @@ -457,29 +457,20 @@ def test_error_check_invalid_value(self): models, connections = self._load_basic_simulation() test_values = [1/2, 1/3, "0.5", False] - # TODO: tidy up with pytest expected_substr = "Option 'result_downsampling_factor' must be an integer," + ## TODO: Pytest parametrization for value in test_values: - try: + with pytest.raises(Exception, match = expected_substr): self._sim_basic_simulation(models, connections, {'result_downsampling_factor': value}) - error_raised = False - except FMUException as e: - error_raised = True - assert expected_substr in str(e), f"Error was {str(e)}, expected substring {expected_substr}" - assert error_raised - - # TODO: Test case that supports storing FMU states required + + @pytest.mark.skipif(True, reason = "Error controlled simulation only supported if storing FMU states are available.") def test_error_controlled_with_downsampling(self): models, connections = self._load_basic_simulation() uptate_options = {'result_downsampling_factor': 2, 'error_controlled': True} - # TODO: Tidy up with pytest msg = "Result downsampling not supported for error controlled simulation, no downsampling will be performed." - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("default") + with pytest.warns(UserWarning, match = msg): self._sim_basic_simulation(models, connections, uptate_options) - # there will be some other warnings from FMU loading - assert f"UserWarning('{msg}')" in [i.message for i in w] def test_downsample_result_with_store_step_before_update(self): """ Test result_downsampling_factor with store_step_before_update. """