Skip to content

Commit 449c8b6

Browse files
committed
test: force C locale for doc-revert git fixtures
Run every fixture git subprocess with LC_ALL=C.UTF-8 and LANGUAGE unset so the merge-conflict assertions remain stable on non-English CI hosts.
1 parent 3080b40 commit 449c8b6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎scripts/test_check_doc_reverts.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
_inherited_doc_revert_base: str | None = None
4545

4646

47+
def git_environment() -> dict[str, str]:
48+
"""Keep every fixture git subprocess's diagnostics in the C locale."""
49+
env = os.environ.copy()
50+
env['LC_ALL'] = 'C.UTF-8'
51+
env.pop('LANGUAGE', None)
52+
return env
53+
54+
4755
def setUpModule() -> None:
4856
"""Fixture repositories cannot resolve the caller's engine base."""
4957
global _inherited_doc_revert_base
@@ -73,7 +81,7 @@ def __init__(self) -> None:
7381

7482
def git(self, *args: str) -> str:
7583
return subprocess.run(['git', '-C', str(self.root), *args], capture_output=True,
76-
text=True, check=True).stdout.strip()
84+
text=True, check=True, env=git_environment()).stdout.strip()
7785

7886
def commit(self, text: str, message: str, *, gate: bool = True) -> str:
7987
self.page.write_text(text)
@@ -348,7 +356,7 @@ def commit_page(self, r: Repo, text: str, message: str,
348356
def conflict_with_main(self, r: Repo, lane: str, main: str) -> None:
349357
result = subprocess.run(
350358
['git', '-C', str(r.root), 'merge', '--no-ff', '--no-commit', 'main'],
351-
capture_output=True, text=True)
359+
capture_output=True, text=True, env=git_environment())
352360
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
353361
self.assertIn('CONFLICT (content)', result.stdout + result.stderr)
354362
self.assertEqual(r.git('rev-parse', 'HEAD'), lane)

0 commit comments

Comments
 (0)