test(pins): prove [tool.interlocks.tools] overrides flow into every pinned-tool task cmd#56
test(pins): prove [tool.interlocks.tools] overrides flow into every pinned-tool task cmd#560xjgv wants to merge 1 commit into
Conversation
…inned-tool task command Adds one focused pin-propagation test per pinned external tool — ruff, basedpyright, pip-audit, deptry, lizard, import-linter, interlocks-mutmut, and coverage — each verifying that a [tool.interlocks.tools] override in pyproject.toml reaches the uvx / uv-run-with argv built by the corresponding task or config helper.
There was a problem hiding this comment.
Code Review
This pull request adds a suite of tests to verify that tool version overrides specified in pyproject.toml under [tool.interlocks.tools] are correctly propagated to the command-line arguments for various tasks, including arch, audit, complexity, deps, lint, mutation, and typecheck. Feedback was provided to improve the robustness of the mutation test by calling the target function through its module object when internal functions are monkeypatched.
| monkeypatch.setattr(mutation_mod, "_run_mutmut", _spy_run) | ||
| monkeypatch.setattr(mutation_mod, "coverage_line_rate", lambda: 1.0) | ||
| monkeypatch.setattr(mutation_mod, "read_mutation_summary", lambda: None) | ||
| monkeypatch.setattr(sys, "argv", ["interlocks", "mutation", "--min-coverage=0"]) |
There was a problem hiding this comment.
The test mocks several attributes on mutation_mod (which is interlocks.tasks.mutation) but then calls cmd_mutation() which was imported directly at line 27. While Python's module system ensures that cmd_mutation will see the mocked globals because it resides in that module, it is generally safer and more explicit to call the function through the module object when you are monkeypatching that same module's internal functions (like _run_mutmut or coverage_line_rate).
| monkeypatch.setattr(mutation_mod, "_run_mutmut", _spy_run) | |
| monkeypatch.setattr(mutation_mod, "coverage_line_rate", lambda: 1.0) | |
| monkeypatch.setattr(mutation_mod, "read_mutation_summary", lambda: None) | |
| monkeypatch.setattr(sys, "argv", ["interlocks", "mutation", "--min-coverage=0"]) | |
| monkeypatch.setattr(mutation_mod, "_run_mutmut", _spy_run) | |
| monkeypatch.setattr(mutation_mod, "coverage_line_rate", lambda: 1.0) | |
| monkeypatch.setattr(mutation_mod, "read_mutation_summary", lambda: None) | |
| monkeypatch.setattr(sys, "argv", ["interlocks", "mutation", "--min-coverage=0"]) | |
| mutation_mod.cmd_mutation() |
Summary
[tool.interlocks.tools]in a temp pyproject.toml, calls the relevant task builder or config helper, and asserts the overridden version spec (<package>==9.99.0) appears in the resulting uvx / uv-run-with argvTest plan
uv run pytest -q tests/test_config.py tests/test_runner.py tests/tasks/→ 316 passeduv run interlocks check --changed→ all gates green