From 1959afc379e9f65bd91fa1bca89ddfd0e4dccafa Mon Sep 17 00:00:00 2001 From: fderuiter <127706008+fderuiter@users.noreply.github.com> Date: Fri, 3 Apr 2026 14:12:01 +0000 Subject: [PATCH] test: assert on specific typer.Exit exception in parse_filters Updated `tests/unit/cli/test_parse_filters.py` to catch specific `typer.Exit` exceptions and assert on `code=1` rather than catching the generic `Exception` base class. This avoids the "silent failure" test anti-pattern where a test might pass due to an unrelated error such as a syntax error or bug inside the `try` block. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- tests/unit/cli/test_parse_filters.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/cli/test_parse_filters.py b/tests/unit/cli/test_parse_filters.py index b885b5b7..2d728f17 100644 --- a/tests/unit/cli/test_parse_filters.py +++ b/tests/unit/cli/test_parse_filters.py @@ -1,4 +1,5 @@ import pytest +import typer from imednet.cli import parse_filter_args @@ -13,13 +14,15 @@ def test_parse_filter_args_types(): def test_parse_filter_args_invalid(): - with pytest.raises(Exception): + with pytest.raises(typer.Exit) as exc_info: parse_filter_args(["bad"]) + assert exc_info.value.exit_code == 1 def test_parse_filter_args_invalid_escaped(capfd: pytest.CaptureFixture[str]): - with pytest.raises(Exception): + with pytest.raises(typer.Exit) as exc_info: parse_filter_args(["[red]bad[/red]"]) + assert exc_info.value.exit_code == 1 captured = capfd.readouterr() # Rich renders escaped markup as literal text.