test(cli): cover UsageError path in main() and drop redundant handler

The mro-based UsageError check inside the Exception block already
catches BadParameter (it inherits from UsageError) — the separate
typer.BadParameter handler was redundant.

Added an in-process Behave step that calls main() directly and
captures err_console output, plus a scenario that runs
`plan use --no-such-flag` to cover the UsageError branch (subprocess
steps do not count toward unit-test coverage).
This commit is contained in:
2026-06-04 14:39:17 -04:00
committed by drew
parent 6d35dbf921
commit 4af74c3da8
3 changed files with 23 additions and 4 deletions
+6
View File
@@ -35,3 +35,9 @@ Feature: CLI main() error handling paths
Scenario: _print_basic_help prints without error
When I call the main _print_basic_help
Then the main _print_basic_help completes ok
@coverage
Scenario: unknown option triggers UsageError handler with exit code 2
When I call main with arguments ["plan", "use", "--no-such-flag", "x"]
Then the main cli exit code should be 2
And the main cli output contains "No such option"