Answer stability round 1: 1 🔴, 2 🟡 (0 misread); pin the git diff settings Gremlins parses, show the mutant total, and a container prefix that runs as root

This commit is contained in:
2026-11-21 00:02:27 +01:00
parent 89f5fcbc16
commit 846d6c6e36
4 changed files with 87 additions and 59 deletions
+11 -7
View File
@@ -14,7 +14,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from mutate_changes.changed_lines import added_lines, by_folder, not_mutated, runs, tool_for
from mutate_changes.in_diff_tools import with_zero_diff_context
from mutate_changes.in_diff_tools import with_plain_git_diff
from mutate_changes.mutmut_tool import copy_files
from mutate_changes.mutmut_mutants import crash_in_mutmut, function_keys, mutant_globs, mutated_line, named, statuses
from failure import Failure
@@ -148,15 +148,19 @@ class ChangedLines(unittest.TestCase):
class InDiffTools(unittest.TestCase):
def test_zero_diff_context_is_added_after_the_settings_the_environment_holds(self):
setting = {"GIT_CONFIG_KEY_0": "safe.directory", "GIT_CONFIG_VALUE_0": "*"}
self.assertEqual(with_zero_diff_context({"HOME": "/h", "GIT_CONFIG_COUNT": "1", **setting}), {"HOME": "/h", "GIT_CONFIG_COUNT": "2", **setting, "GIT_CONFIG_KEY_1": "diff.context", "GIT_CONFIG_VALUE_1": "0"})
def test_the_git_settings_gremlins_needs_are_added_after_the_ones_the_environment_holds(self):
held = {"HOME": "/h", "GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "safe.directory", "GIT_CONFIG_VALUE_0": "*"}
env = with_plain_git_diff(held)
self.assertEqual(env["GIT_CONFIG_COUNT"], "7")
self.assertEqual({name: value for name, value in env.items() if name in held}, held | {"GIT_CONFIG_COUNT": "7"})
settings = [(env[f"GIT_CONFIG_KEY_{index}"], env[f"GIT_CONFIG_VALUE_{index}"]) for index in range(1, 7)]
self.assertEqual(settings, [("diff.context", "0"), ("diff.noprefix", "false"), ("diff.mnemonicPrefix", "false"), ("diff.srcPrefix", "a/"), ("diff.dstPrefix", "b/"), ("color.diff", "never")])
def test_zero_diff_context_is_the_first_setting_where_the_environment_holds_none_or_a_count_that_is_no_number(self):
first = {"GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "diff.context", "GIT_CONFIG_VALUE_0": "0"}
def test_the_git_settings_start_at_the_first_for_an_environment_without_a_count_or_with_one_that_is_not_a_number(self):
for held in ({}, {"GIT_CONFIG_COUNT": "many"}, {"GIT_CONFIG_COUNT": ""}):
with self.subTest(held):
self.assertEqual(with_zero_diff_context(held), first)
env = with_plain_git_diff(held)
self.assertEqual((env["GIT_CONFIG_COUNT"], env["GIT_CONFIG_KEY_0"], env["GIT_CONFIG_KEY_5"], "GIT_CONFIG_KEY_6" in env), ("6", "diff.context", "color.diff", False))
class MutmutSetup(unittest.TestCase):