From 495d6c3ef1c5ef204eaa1cb81370af2fc543d72b Mon Sep 17 00:00:00 2001 From: Brian Schubert Date: Thu, 5 Dec 2024 13:27:56 -0500 Subject: [PATCH] Use regex to match expected error message in SystemExit cases --- tests/test_to_tap_class.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_to_tap_class.py b/tests/test_to_tap_class.py index c439741..c67f4ab 100644 --- a/tests/test_to_tap_class.py +++ b/tests/test_to_tap_class.py @@ -266,7 +266,7 @@ def _test_subclasser( if isinstance(arg_to_expected_value, SystemExit): stderr = _test_raises_system_exit(tap, args_string) - assert str(arg_to_expected_value) in stderr + assert re.search(str(arg_to_expected_value), stderr) elif isinstance(arg_to_expected_value, BaseException): expected_exception = arg_to_expected_value.__class__ expected_error_message = str(arg_to_expected_value) or None @@ -471,7 +471,7 @@ def test_subclasser_complex_help_message(class_or_function_: Any): ( "--arg_int 1 --baz X --foo b", SystemExit( - "error: argument {a,b}: invalid choice: 'X' (choose from 'a', 'b')" + r"error: argument \{a,b}: invalid choice: 'X' \(choose from '?a'?, '?b'?\)" ), ), ( @@ -480,7 +480,7 @@ def test_subclasser_complex_help_message(class_or_function_: Any): ), ( "--arg_int 1 --foo b --baz A", - SystemExit("""error: argument --baz: Value for variable "baz" must be one of ['X', 'Y', 'Z']."""), + SystemExit(r"""error: argument --baz: Value for variable "baz" must be one of \['X', 'Y', 'Z']."""), ), ], )