diff --git a/tests/test_cli.py b/tests/test_cli.py index 02c9d84..036f317 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,3 +1,4 @@ +import shutil import unittest import pathlib from mopyregtest import cli @@ -64,7 +65,13 @@ def test_generate4(self): str(this_folder / "data/FlawedModels"), "FlawedModels.DoesNotBuild"] - self.assertRaises(AssertionError, cli.parse_args, cmd_args) + with self.assertRaises(SystemExit) as e: + cli.parse_args(cmd_args) + + self.assertEqual(e.exception.code, 1) + + # Clean up the generated regression tests as otherwise they will confuse unittest discovery + shutil.rmtree(this_folder / "data/gentests") return @@ -80,6 +87,9 @@ def test_generate5(self): cli.parse_args(cmd_args) + # Clean up the generated regression tests as otherwise they will confuse unittest discovery + shutil.rmtree(this_folder / "data/gentests") + return def test_compare1(self): diff --git a/tests/test_compare_results.py b/tests/test_compare_results.py index 31ee7b1..b645400 100644 --- a/tests/test_compare_results.py +++ b/tests/test_compare_results.py @@ -67,10 +67,10 @@ def test_write_comparison_timeseries1(self): argument. """ - compar_file_path = (this_folder / "../examples/test_user_defined_metrics/references/Sine_res_comparison.csv") + compare_file_path = (this_folder / "../examples/test_user_defined_metrics/references/Sine_res_comparison.csv") - if compar_file_path.exists(): - os.remove(compar_file_path) + if compare_file_path.exists(): + os.remove(compare_file_path) self.assertRaises(AssertionError, mopyregtest.RegressionTest.compare_csv_files, reference_result="../examples/test_user_defined_metrics/references/SineNoisy_res.csv", @@ -78,7 +78,7 @@ def test_write_comparison_timeseries1(self): tol=1e-5, validated_cols=["y"], write_comparison=False) - self.assertFalse(compar_file_path.exists()) + self.assertFalse(compare_file_path.exists()) return @@ -87,17 +87,17 @@ def test_write_comparison_timeseries2(self): Validate that a comparison timeseries is written on a failed test by default. """ - compar_file_path = (this_folder / "../examples/test_user_defined_metrics/references/Sine_res_comparison.csv") + compare_file_path = (this_folder / "../examples/test_user_defined_metrics/references/Sine_res_comparison.csv") - if compar_file_path.exists(): - os.remove(compar_file_path) + if compare_file_path.exists(): + os.remove(compare_file_path) self.assertRaises(AssertionError, mopyregtest.RegressionTest.compare_csv_files, reference_result="../examples/test_user_defined_metrics/references/SineNoisy_res.csv", simulation_result="../examples/test_user_defined_metrics/references/Sine_res.csv", tol=1e-5, validated_cols=["y"]) - self.assertTrue(compar_file_path.exists()) + self.assertTrue(compare_file_path.exists()) return