Repository navigation
test(cli): hint guard and behaviour-based subparser assertions (#94) - #283
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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:
|
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
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.pymakestest_no_string_in_the_package_names_the_source_shimfail 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 handlerworks because_stops_at_capusesfunctools.wraps;matrix-runbindscmd_arms_matrix_rundirectly. - 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
left a comment
There was a problem hiding this comment.
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 ispip-audit, which reports advisories againstfilelock 3.32.7in the lock files. This PR is test-only and does not touch them.- Rename check: renaming
dest="arms_cmd"anddest="novelty_cmd"fails the old asserts at the base (2 failed) and keeps the new ones green (91 passed). - Mutation: wiring novelty
probetocmd_novelty_atomsfailstest_every_subcommand_is_registered. Wiringmatrix-runtocmd_arms_runfails the matrix parser test. - Guard mutation: plain strings, f-strings and implicitly concatenated literals containing
python cli.pyall fail the guard.
Checked, no issues
- Unwrap:
_stops_at_capusesfunctools.wraps, soinspect.unwrapreaches the handler foranalyze,atoms,probeandshorten.viewis registered bare. - Scan root:
Path(dokimi.__file__).parentresolves to the package under test, andrglobcovers its subdirectories. - Lint:
ruff checkpasses on the changed tests, and both new imports are used. - Commits: both are signed off.
) (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>
Summary
Test-only. Two leftovers from #94 (after #252).
dokimi/namespython cli.pyany more. This PR adds the guard: an AST scan of every string literal in thepackage (docstrings excluded) that fails on
python cli.py, so a new hint that copies the sourceshim cannot land unnoticed.
destnames (arms_cmd,novelty_cmd). They now assert the command that runs. A later move of a subcommand group keepsthem 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.pyincommands/personas.py:73:After: on current main,
tests/test_printed_hints_parse.py: 6 passed.Before (dest rename):
dest="arms_cmd"anddest="novelty_cmd"renamed in the source. The oldasserts fail:
After: the same rename, with the new asserts: 2 passed.
Full suite (
pytest -q -n 8): this branch 9716 passed, 6 skipped. intel/main 114cb6c9715 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