|
Option C Tools
|
Functions | |
| list[str] | _click_option_names (click.Command cmd) |
| list[tuple[str, click.Command]] | _walk_commands (click.Group group, str prefix="") |
| str | _rendered_for (str qname) |
| test_every_click_option_appears_in_command_flags () | |
| test_every_group_subcommand_appears_in_group_flags () | |
| test_command_flags_entries_only_reference_known_commands () | |
Variables | |
| dict | _ARGPARSE_ROUTED = {"lint", "format", "typecheck"} |
| dict | _ROLLED_INTO_PARENT |
Purpose
-------
OI-523 drift-prevention regression — :data:`oct.cli._COMMAND_FLAGS` is a
hand-maintained table of ``(flag, description)`` rows rendered by
:meth:`OctGroup.format_help`. It is easy for a contributor to add a new
``@click.option`` on a command and forget to append the matching row to
``_COMMAND_FLAGS``, leaving ``oct --help`` silently out of date.
This test walks every non-hidden Click command / subcommand in the ``oct``
CLI and asserts that each declared :class:`click.Option` appears
somewhere in the command's ``_COMMAND_FLAGS`` entry. Running this test in
CI turns a silent doc drift into a loud unit-test failure.
Responsibilities
----------------
- Every top-level Click option on every ``oct`` subcommand is mentioned
in the ``_COMMAND_FLAGS`` rows.
- Every Click group (``git``, ``diag``) exposes its subcommands in the
group's ``_COMMAND_FLAGS`` rows.
- Argparse-routed commands (``lint``, ``format``, ``typecheck``) are
skipped because their flags live in ``argparse``, not Click.
Diagnostics
-----------
Domain: CLI-TESTS
Levels:
L2 — test lifecycle
L3 — assertion details
L4 — deep tracing
Contracts
---------
- Tests introspect the Click command tree in-process; no subprocess or
filesystem writes.
- Argparse-routed commands are excluded from the check.
|
protected |
Return the canonical long-option name for each :class:`Option`.
Definition at line 58 of file test_command_flags_introspection.py.
|
protected |
Join the flag rows for ``qname``, falling back to the parent group. ``_COMMAND_FLAGS`` keys subgroup subcommands under two conventions: ``git`` and ``diag`` either get per-subcommand keys (``git status``) or roll the subcommands into the parent key (``diag``). Either convention satisfies the drift guard.
Definition at line 89 of file test_command_flags_introspection.py.
|
protected |
Yield ``(qualified_name, command)`` for every non-hidden command.
Definition at line 72 of file test_command_flags_introspection.py.
| test_command_flags_introspection.test_command_flags_entries_only_reference_known_commands | ( | ) |
Definition at line 167 of file test_command_flags_introspection.py.
| test_command_flags_introspection.test_every_click_option_appears_in_command_flags | ( | ) |
Definition at line 117 of file test_command_flags_introspection.py.
| test_command_flags_introspection.test_every_group_subcommand_appears_in_group_flags | ( | ) |
Definition at line 140 of file test_command_flags_introspection.py.
|
protected |
Definition at line 55 of file test_command_flags_introspection.py.
|
protected |
Definition at line 108 of file test_command_flags_introspection.py.