Skip to content

test(cli): hint guard and behaviour-based subparser assertions (#94) - #283

Merged
antonwolfy merged 2 commits into
intel:mainfrom
napetrov:fix/cli-hint-leftovers
Oct 29, 2026
Merged

antonwolfy merged 2 commits into
intel:mainfrom
napetrov:fix/cli-hint-leftovers

Conversation

@napetrov

Copy link
Copy Markdown
Contributor

Summary

Test-only. Two leftovers from #94 (after #252).

tests/
├── test_matrix_rollup.py        assert args.func is cmd_arms_matrix_run      (was args.arms_cmd)
├── test_novelty_cli.py          inspect.unwrap(args.func) is the handler      (was args.novelty_cmd)
└── test_printed_hints_parse.py  + test_no_string_in_the_package_names_the_source_shim
  • Hints (item 1): already fixed on intel/main by fix(cli): next-step hints name the dokimi command; drop dead cmd_report #252. No string literal in dokimi/ names
    python cli.py any more. This PR adds the guard: an AST scan of every string literal in the
    package (docstrings excluded) that fails on python cli.py, so a new hint that copies the source
    shim cannot land unnoticed.
  • Subparser dest (item 2): the two tests read the argparse dest names (arms_cmd,
    novelty_cmd). They now assert the command that runs. A later move of a subcommand group keeps
    them green.

Production code is unchanged. No changelog fragment: no user-visible behaviour changes. Refs #94.
The numbers do not change.

Evidence

  • Before (guard red): the hint reverted to python cli.py in commands/personas.py:73:

    E  AssertionError: hints name the source shim, not `dokimi`:
    E    commands/personas.py:73: 3. Approve: python cli.py personas approve --file
    1 failed
    

    After: on current main, tests/test_printed_hints_parse.py: 6 passed.

  • Before (dest rename): dest="arms_cmd" and dest="novelty_cmd" renamed in the source. The old
    asserts fail:

    E  AttributeError: 'Namespace' object has no attribute 'arms_cmd'
    E  AttributeError: 'Namespace' object has no attribute 'novelty_cmd'
    2 failed
    

    After: the same rename, with the new asserts: 2 passed.

  • Full suite (pytest -q -n 8): this branch 9716 passed, 6 skipped. intel/main 114cb6c
    9715 passed, 6 skipped. The extra pass is the guard. Lint, mypy, deptry, changed-line coverage and
    the test-quality audit pass under make ci-local.

Merge Danger

Door: two-way. Test-only changes; revert is trivial.

Open PRs: none of the three files is in any open PR's file list (checked on 2026-10-29). PRs #254
(CLI flag registry and snapshot, #94 F1a) and #238 touch CLI code, so rebase them if they land first.

Blast Radius: test suite only. A failure here means a test is wrong, never shipped behaviour.

🤖 Generated with Claude Code

…r, not the subparser dest

The two tests read args.arms_cmd and args.novelty_cmd, the dest names of the
subparsers. Assert the command that runs instead (args.func, unwrapped for the
novelty spend-cap wrapper), so a later move of a subcommand group keeps them
green. Refs intel#94

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…li.py

The hint tests cover four hints by name. This one scans every string literal
in dokimi/ (docstrings excluded) so a new hint that copies the source shim
fails here. Refs intel#94

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.02%. Comparing base (114cb6c) to head (26e9f43).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #283   +/-   ##
=======================================
  Coverage   93.02%   93.02%           
=======================================
  Files         265      265           
  Lines       33464    33464           
  Branches     5610     5610           
=======================================
  Hits        31130    31130           
  Misses       1540     1540           
  Partials      794      794           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I checked 26e9f43. The parser tests now check which handler runs, and the new guard catches a python cli.py hint anywhere in the package.

What I ran, at 26e9f43:

  • make ci-local --offline: 0 failed, 17 passed, 13 skipped (network-only jobs).
  • Mutation: an f-string f"run: python cli.py arms run {1}" added to _version.py makes test_no_string_in_the_package_names_the_source_shim fail and name the line. The base has no such string, so the guard is a forward check by design.

Checked, no issues

  • Handler assertions: inspect.unwrap(args.func) is handler works because _stops_at_cap uses functools.wraps; matrix-run binds cmd_arms_matrix_run directly.
  • Docstring exclusion: only the first statement of a module, class or function is skipped, so strings in code are still scanned, f-string parts included.

@antonwolfy antonwolfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The handler assertions check the command that runs, and the new guard catches a python cli.py string anywhere in the package.

What I ran, on a Linux review host at 26e9f43:

  • make ci-local: 27 passed, 1 failed, 7 skipped. 9718 tests passed, 4 skipped. The one failure is pip-audit, which reports advisories against filelock 3.32.7 in the lock files. This PR is test-only and does not touch them.
  • Rename check: renaming dest="arms_cmd" and dest="novelty_cmd" fails the old asserts at the base (2 failed) and keeps the new ones green (91 passed).
  • Mutation: wiring novelty probe to cmd_novelty_atoms fails test_every_subcommand_is_registered. Wiring matrix-run to cmd_arms_run fails the matrix parser test.
  • Guard mutation: plain strings, f-strings and implicitly concatenated literals containing python cli.py all fail the guard.

Checked, no issues

  • Unwrap: _stops_at_cap uses functools.wraps, so inspect.unwrap reaches the handler for analyze, atoms, probe and shorten. view is registered bare.
  • Scan root: Path(dokimi.__file__).parent resolves to the package under test, and rglob covers its subdirectories.
  • Lint: ruff check passes on the changed tests, and both new imports are used.
  • Commits: both are signed off.

@antonwolfy
antonwolfy merged commit b0605dc into intel:main Oct 29, 2026
14 checks passed
napetrov added a commit to napetrov/dokimi that referenced this pull request Oct 29, 2026
) (intel#283)

* test(cli): route the arms and novelty parser tests through the handler, not the subparser dest

The two tests read args.arms_cmd and args.novelty_cmd, the dest names of the
subparsers. Assert the command that runs instead (args.func, unwrapped for the
novelty spend-cap wrapper), so a later move of a subcommand group keeps them
green. Refs intel#94

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

* test(cli): guard that no printed string in the package names python cli.py

The hint tests cover four hints by name. This one scans every string literal
in dokimi/ (docstrings excluded) so a new hint that copies the source shim
fails here. Refs intel#94

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

---------

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants