diff --git a/tests/test_client.py b/tests/test_client.py index a94c62f..ec228a5 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -29,9 +29,11 @@ GIT_ENV = { } -def run_git(cwd, *args): - return subprocess.run(["git", "-C", cwd] + list(args), check=True, - capture_output=True, text=True, env=GIT_ENV).stdout.strip() +def run_git(cwd, *args, strip=True): + stdout = subprocess.run(["git", "-C", cwd] + list(args), check=True, + capture_output=True, text=True, + env=GIT_ENV).stdout + return stdout.strip() if strip else stdout @@ -905,15 +907,13 @@ class TestCredentialHelperIsolation(GitScenarioBase): def test_install_leaves_exactly_one_helper(self): run_git(self.local, "config", "--add", "credential.helper", "store") client.install_credential_helper(self.local) - # --get-all merges system + global + local, so entries inherited from - # the machine still appear. What matters is that the last two are the - # reset and ours: git reads an empty value as "forget every helper - # inherited so far", so nothing before it can answer. - helpers = run_git(self.local, "config", "--get-all", - "credential.helper").splitlines() - self.assertEqual(helpers[-2], "", helpers) - self.assertIn("git-credential", helpers[-1]) - # the repo-level 'store' this test added is gone, not merely outvoted + # Inspect the repo-local list so this assertion is deterministic even + # when the machine has no inherited helper. Keep the leading newline: + # it represents the empty reset value, not disposable whitespace. + helpers = run_git(self.local, "config", "--local", "--get-all", + "credential.helper", strip=False).splitlines() + self.assertEqual(helpers, ["", client.credential_helper_value()]) + # The repo-level 'store' this test added is gone, not merely outvoted. self.assertNotIn("store", helpers) def test_inherited_helper_cannot_answer_for_the_forge(self):