Problem
_find_relevant_tests matches tests to the changed file using module_name = file_path.stem and _imports_module compares that stem to import / from targets.
This misses common cases:
- Tests use
from mypkg.submodule import foo while the file under edit is mypkg/submodule/foo.py (stem foo vs module path mypkg.submodule).
- Package-relative imports (
from . import x) are not attributed to the filesystem module under verification.
When no tests match, the gate passes with high confidence and details["note"] = "No tests cover this module", which can be a false negative for safety.
Impact
Autofix may ship changes that have tests in the repo but the gate never runs them.
Suggested direction
- Map
file_path to one or more qualified module names using project_root (same as resolving project root elsewhere).
- Match test imports against those qualified names, not only
stem.
- Add fixtures + tests for package layout.
References
refactron/verification/checks/test_gate.py (_find_relevant_tests, _imports_module)
Problem
_find_relevant_testsmatches tests to the changed file usingmodule_name = file_path.stemand_imports_modulecompares that stem toimport/fromtargets.This misses common cases:
from mypkg.submodule import foowhile the file under edit ismypkg/submodule/foo.py(stemfoovs module pathmypkg.submodule).from . import x) are not attributed to the filesystem module under verification.When no tests match, the gate passes with high confidence and
details["note"] = "No tests cover this module", which can be a false negative for safety.Impact
Autofix may ship changes that have tests in the repo but the gate never runs them.
Suggested direction
file_pathto one or more qualified module names usingproject_root(same as resolving project root elsewhere).stem.References
refactron/verification/checks/test_gate.py(_find_relevant_tests,_imports_module)