Skip to content

Commit

Permalink
Use regex to match expected error message in SystemExit cases
Browse files Browse the repository at this point in the history
  • Loading branch information
brianschubert committed Dec 5, 2024
1 parent ee914c0 commit 495d6c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test_to_tap_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'?\)"
),
),
(
Expand All @@ -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']."""),
),
],
)
Expand Down

0 comments on commit 495d6c3

Please sign in to comment.