Repository navigation
Description
Problem or Motivation
Group 1 of #3769. The tests of tests/commands/k8s/ still patch names inside devops_cli. At origin/main 74ba76b, git grep finds 245 string patches of a devops_cli name in 10 of the 25 test files of that directory. test_k8s.py holds 135 of them. test_k8s_bootstrap.py holds 29, test_k8s_context.py 26, test_k8s_logging_stack.py 22 and test_k8s_networking.py 12.
The patches target the private helpers _run_cmd, _cluster_reachable, _minikube_running, _is_cluster_argo_managed and _verify_url_reachability, the imported names run_subprocess, load_settings and save_settings, and the security scanners. commands/k8s/__init__.py holds a module class, _K8sModule, that exists only to forward such a patch to the submodule that uses the name. Product code must not be shaped so that a test can patch it (docs/TESTING.md).
Issue #1336 turns the ratchets into bans and fails on these patches.
Proposed Solution & Architectural Design
Replace each patch with the fake of the edge that the command reaches: process_fake for kubectl, helm and minikube, the cluster fixture for the Kubernetes API, the config fixture for settings, the dial and web fakes for the URL probes, and the scanner fakes for the scanners. A test keeps its name and the behavior that it checks. Delete _K8sModule and the private re-exports that only the old patches used.
Acceptance criteria:
git grepfinds no string patch of adevops_cliname intests/commands/k8s, or the pull request lists each remaining patch with its reason.- The node ids that pytest collects in
tests/commands/k8sare the same before and after, except for a rename whose old name was wrong. - Mutations of the product code in a scratch copy make the migrated tests fail.
_K8sModule,_forward_submodule_attrand_PATCH_TARGET_MAPare gone fromsrc/.- The pull request states the count of patches before and after.
Target Subsystem
Kubernetes & Minikube Automation
Existing Tool Considered
No new tool is needed. The fakes of tests/support/fakes/ (process, Kubernetes, dial, web, scanners) and the config and cli fixtures already cover every edge. The cost of the fakes is already paid by #1313 to #1325.
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.(k8s)scope of the title gives the scope.Test refactoring that improves maintainability but does not fix a defect or block a release.Removes a testing anti-pattern and reduces coupling to internal product names.245 patches across 10 files must be replaced with edge fakes and _K8sModule must be deleted.Both remove devops_cli name patches from command tests; the candidate covers only tests/commands/k8s (245 patches) while #3769 is the umbrella for all 869 patches across 129 files.