From b7cba1ea93e963729f46aff9a6f885accefb2bb6 Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Mon, 3 Aug 2026 16:53:04 -0700 Subject: [PATCH] test(cli): assert help text, not exit code, for bare `adk telemetry` `test_telemetry_cli_commands` pinned `result.exit_code == 0` for `adk telemetry` invoked without a subcommand. Click changed that path in 8.2.0: a group with `no_args_is_help=True` now raises `NoArgsIsHelpError` (a `UsageError` subclass), so the help goes to stderr and the process exits 2, where click 8.1.x called `ctx.exit()` and exited 0. `pyproject.toml` declares `click>=8.1.8,<9` and CI resolves without a lockfile, so the newest in-range click is installed and every interpreter in the unit-test matrix fails on this one assertion. Both exit codes are inside the supported range, so no hard-coded exit code is sound here: `== 2` fails on the 8.1.8 floor just as `== 0` fails on 8.2+. Assert on the rendered help instead -- the behaviour the test's own comment says it checks -- which holds across the whole declared range. The group docstring assertion also makes the check stronger than the bare `"Usage:"` it replaces. Production code and the dependency range are unchanged; bare `adk telemetry` behaves exactly as before. --- tests/unittests/cli/utils/test_cli_tools_click.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unittests/cli/utils/test_cli_tools_click.py b/tests/unittests/cli/utils/test_cli_tools_click.py index 2106cf940ac..50e7996b590 100644 --- a/tests/unittests/cli/utils/test_cli_tools_click.py +++ b/tests/unittests/cli/utils/test_cli_tools_click.py @@ -1830,10 +1830,14 @@ def mock_write(val): runner = CliRunner() - # Test running without subcommand shows help + # Test running without subcommand shows help. Click >= 8.2 reports a group + # invoked without a subcommand as a usage error (exit code 2) and writes the + # help to stderr, while click 8.1.x exited 0 and wrote it to stdout. Both are + # inside the supported range (click>=8.1.8,<9), so assert on the help text -- + # which is the behaviour this test is about -- and not on the exit code. result = runner.invoke(cli_tools_click.main, ["telemetry"]) - assert result.exit_code == 0 assert "Usage:" in result.output + assert "Manage telemetry settings." in result.output # Test status subcommand result = runner.invoke(cli_tools_click.main, ["telemetry", "status"])