From 51f9dad3b012242620b7f160b159367b7696e3ec Mon Sep 17 00:00:00 2001 From: Lars Bogner Date: Mon, 7 Sep 2026 11:35:34 +0200 Subject: [PATCH] fix(tests): make predict --truth flag test robust to terminal rendering The --help-text assertion was brittle to CI's terminal width/color settings (rich can wrap or re-color the flag name mid-word), causing a false CI failure even though the flag itself is fine. Inspect the click command's registered option directly instead of parsing rendered --help output. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01PpxE9nij3ujg9XcuzvQ26q --- tests/test_cli_predict.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_cli_predict.py b/tests/test_cli_predict.py index b826fc2..7459e1c 100644 --- a/tests/test_cli_predict.py +++ b/tests/test_cli_predict.py @@ -233,6 +233,13 @@ def test_predict_truth_metadata_key_exists(): def test_predict_has_truth_flag_default_on(): - result = runner.invoke(app, ["predict", "--help"]) - assert "--truth" in result.output - assert "--no-truth" in result.output + # Inspecting rendered --help text is brittle across terminal + # widths/color settings (wraps or re-colors mid-flag); go straight to + # the underlying click command's registered option instead. + import typer + + predict_cmd = typer.main.get_command(app).commands["predict"] + truth_param = next(p for p in predict_cmd.params if p.name == "truth") + assert truth_param.opts == ["--truth"] + assert truth_param.secondary_opts == ["--no-truth"] + assert truth_param.default is True