Leave out a failing test file by its absolute path, since pytest 9.2 under mutmut 3.8.1 reports nodeids as mutants/<path>

This commit is contained in:
2026-11-11 19:04:24 +01:00
parent 25967807ff
commit e99eef43b9
3 changed files with 28 additions and 17 deletions
+4 -4
View File
@@ -15,7 +15,7 @@ from mutate_changes.tool_process import failed, Ran, run_tool
from failure import Failure
from mutate_changes.mutmut_mutants import function_keys, mutant_globs, mutated_line, named, statuses
from git_cli.git_repo import git
from mutate_changes.mutmut_setup import left_out, mutmut_config
from mutate_changes.mutmut_setup import leaving_out, left_out, mutmut_config
CAUGHT = frozenset({"caught by type check", "killed"})
CONFIGS = ("pyproject.toml", "setup.cfg")
@@ -140,17 +140,17 @@ def mutate_copy(copy: str, folder: Folder, argv: list[str], prefix: str | None)
return results if isinstance(results, Failure) else failed(f"mutmut results in {folder.label}", results)
shown, counted = not_killed(folder, statuses(results.output), copy)
unreached = " No test reaches them." if NO_TEST in output else ""
left_files = sorted({option.partition("=")[2].partition("::")[0] for option in left})
left_files = sorted({nodeid.partition("::")[0].removeprefix("mutants/") for nodeid in left})
left_note = f" Left out tests in {', '.join(left_files)} that fail without a mutant." if left else ""
return [f"mutmut in {folder.label}: {counted} mutants on changed lines, {len(shown)} not killed.{unreached}{left_note}", *shown]
def run_until_stats_pass(copy: str, folder: Folder, argv: list[str], prefix: str | None) -> tuple[str, list[str]] | Failure:
"""mutmut's output, and the options that left out each test that fails before any mutant: mutmut runs no mutant while one fails."""
"""mutmut's output, and the nodeid of each test it left out because the test fails before any mutant: mutmut runs no mutant while one fails."""
ran = configured_run(copy, folder, LIST_FAILURES, argv, prefix)
left: list[str] = []
if isinstance(ran, Ran) and STATS_FAILED in ran.output and (left := left_out(ran.output)):
ran = configured_run(copy, folder, left, argv, prefix)
ran = configured_run(copy, folder, leaving_out(left, copy), argv, prefix)
if isinstance(ran, Failure):
return ran
if ran.code and NO_MUTANT not in ran.output and NO_TEST not in ran.output: