Repository navigation
Description
Problem or Motivation
Parent #3769 asks that the command tests patch no name of devops_cli. Group 3 is the tests of devops ci: tests/commands/test_ci.py, test_ci_build_index.py, test_ci_dry_run.py, test_ci_shard.py, test_ci_repeat.py, test_ci_maintain.py, test_ci_gate_rows.py and test_test_selection.py.
Measured at origin/main 74ba76b (2026-11-07) with an AST count of the calls to monkeypatch.setattr, patch and patch.object in these files: 106 patches name a devops_cli module in a string (45 in test_ci.py, 11 in test_ci_build_index.py, 2 in test_ci_dry_run.py, 48 in test_test_selection.py), and 28 more patch an attribute of the imported ci module object (23 in test_ci.py, 5 in test_ci_shard.py). That is 134 patches of a devops_cli name in 5 of the 8 files.
Product code also holds two accommodations for these tests:
commands/ci.pyreadsPYTEST_CURRENT_TESTtwice in_clean_coverage_artifacts, so that a test of the gate cannot delete the live.coverage.*files of the run that tests it (follow-up of refactor(cli): source modules keep no accommodation for tests #4053 and refactor(cli): source modules keep no accommodation for tests #4021).commands/ci.pyholds_current_run_subprocessand_ORIG_RUN_SUBPROCESS. They exist only so that a test can replacerun_subprocesson the module.
The change folder openspec/changes/1325-ci-commands-edge-fakes plans this work, but its parent #1325 is closed and the plan is stale.
Proposed Solution & Architectural Design
- Replace each patch with the fake of the edge the command reaches:
process_fakefor programs,git_fakefor git, a root of its own undertmp_pathfor the checked tree, theconfigfixture for settings, and the real cache functions ofdevops_cli.ci.cachefor the cache. - Run each test that starts the gate in a root under
tmp_path, so that the gate cleans only files of that root. - Remove the two
PYTEST_CURRENT_TESTreads. Then the ceiling intests/invariants/test_source_tree.pygoes from 2 to 0 and becomes a ban. - Remove
_current_run_subprocessand_ORIG_RUN_SUBPROCESS. - Where a test patched a private helper that holds logic, test the behavior through the command, or move the logic behind a public function of its domain package.
- Keep every test of the group. The behavior each test checks does not change.
- State the count of patches of the group before and after in the pull request.
- Fix or archive the stale plan
openspec/changes/1325-ci-commands-edge-fakes.
Target Subsystem
SDLC, Git & PR Governance.
Existing Tool Considered
No new tool is needed. process_fake, git_fake, the config fixture and pytest cover the need. The cost of the fakes is already paid by #1313 to #1325.
Acceptance criteria
git grepfinds no string patch of adevops_cliname in the files of group 3.- The test identifiers of the group collected before and after match, and each passes.
- A product mutation in the code that a migrated test covers makes that test fail.
PYTEST_CURRENT_TESTis read nowhere insrc/, andtests/invariants/test_source_tree.pybans the read.
Related
Related: #3769
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(ci)scope of the title gives the scope.Removing test coupling and product-code accommodations improves maintainability but does not block a user-facing release.Removes 134 internal patches and two product-code accommodations, reducing test fragility and hidden coupling.Replacing 134 patches across 8 files with edge fakes and removing two product-code accommodations is a focused but multi-file change.Both remove string patches of devops_cli names from command tests, but the candidate covers only group 3 (8 CI/test-selection files) while #3769 covers all command test files.