From 5d7f472afa3957441983e8f3947971ca79fbd909 Mon Sep 17 00:00:00 2001 From: Roland Mas Date: Wed, 18 Sep 2024 18:15:12 +0200 Subject: [PATCH] Fix a few tests Gbp-Pq: Name 0001-Fix-a-few-tests.patch --- src/freesas/test/test_autorg.py | 5 +++++ src/freesas/test/test_sas_argparser.py | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/freesas/test/test_autorg.py b/src/freesas/test/test_autorg.py index 3acbc1b..0de7f4c 100644 --- a/src/freesas/test/test_autorg.py +++ b/src/freesas/test/test_autorg.py @@ -170,6 +170,8 @@ def test_synthetic(self): ) def test_auto_gpa_with_outlier(self): + if "outlier_position" not in self.extra_arg: + raise unittest.SkipTest("No outlier position to test") """ Test that auto_gpa gives reasonalbe results @@ -374,6 +376,9 @@ def test_curate_synthetic_data(self): ) def test_curate_synthetic_data_with_negative_points(self): + if "negative_point_index" not in self.extra_arg: + raise unittest.SkipTest("No negative point index to test") + """Test that if one of the first three points is negative, all date before it gets ignored.""" negative_point_index = self.extra_arg["negative_point_index"] diff --git a/src/freesas/test/test_sas_argparser.py b/src/freesas/test/test_sas_argparser.py index 3575bea..c9a9b4d 100644 --- a/src/freesas/test/test_sas_argparser.py +++ b/src/freesas/test/test_sas_argparser.py @@ -29,7 +29,7 @@ def test_minimal_guinier_parser_requires_file_argument(self): output_catcher = io.StringIO() try: with contextlib.redirect_stderr(output_catcher): - _ = basic_parser.parse_args() + _ = basic_parser.parse_args([]) except SystemExit: pass @@ -172,8 +172,8 @@ def test_minimal_parser_default_verbosity_level_is_0(self): """ Test that the parser sets the verbosity to 0 if no args are provided """ - basic_parser = SASParser("program", "description", "epilog") - parsed_arguments = basic_parser.parse_args() + basic_parser = SASParser("program", "description", "epilog", exit_on_error=False) + parsed_arguments = basic_parser.parse_args([]) self.assertEqual( parsed_arguments.verbose, 0, @@ -268,8 +268,8 @@ def test_minimal_guinier_parser_accepts_output_file_argument(self): parsed_arguments = basic_parser.parse_args(["afile", "-o", "out.file"]) self.assertEqual( - parsed_arguments.output, - Path("out.file"), + str(parsed_arguments.output), + str(Path("out.file")), msg="Minimal GuinierParser accepts output file argument", ) @@ -297,8 +297,8 @@ def test_add_output_filename_argument_adds_output_file_argument_to_SASParser( parsed_arguments = basic_parser.parse_args(["-o", "out.file"]) self.assertEqual( - parsed_arguments.output, - Path("out.file"), + str(parsed_arguments.output), + str(Path("out.file")), msg="SASParser accepts output file argument" "after running add_output_filename_argument()", )