From e3cc18f04ea7f1f09b59d5b601ad446f39b85328 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 20 Nov 2026 23:38:39 +0100 Subject: [PATCH] Test the git settings Gremlins' environment gets --- bin/mutate_changes/test_mutate_changes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/mutate_changes/test_mutate_changes.py b/bin/mutate_changes/test_mutate_changes.py index 93e35949..cb4576a9 100644 --- a/bin/mutate_changes/test_mutate_changes.py +++ b/bin/mutate_changes/test_mutate_changes.py @@ -14,6 +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.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 @@ -146,6 +147,18 @@ class ChangedLines(unittest.TestCase): self.assertEqual((not_mutated(["a.py", "test_a.py"]), not_mutated(["a.py", "b.rb"]), not_mutated([])), (["Not mutated, as test files: test_a.py."], ["Not mutated, as no tool covers their language: b.rb."], [])) +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_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"} + for held in ({}, {"GIT_CONFIG_COUNT": "many"}, {"GIT_CONFIG_COUNT": ""}): + with self.subTest(held): + self.assertEqual(with_zero_diff_context(held), first) + + class MutmutSetup(unittest.TestCase): def test_the_config_mutates_the_sources_and_copies_each_entry_of_the_folder(self): for existing in ("", "[mutmut]\nsource_paths = old.py\nalso_copy = old\n"):