From 48db7feb5f7da4d2e338ba25805074c2b6c4e3d2 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 5 Oct 2026 02:51:05 +0200 Subject: [PATCH] test(i18n): guard the backslash a rejection sample must not keep The expectation in test_a_rejected_translation_never_spills_over_its_comment_line encoded the old mechanism, an escaped newline, which is what introduced the backslash that broke docs/tr and docs/zh. The invariant its name states still holds with a space, so the expectation moves and the fix stays. A second test asserts the property that actually prevents the defect: a sample containing [test\\_file.py] leaves no backslash in the comment, whatever babel does when it wraps it. Nothing guarded that before, which is why two unparseable catalogs only surfaced under a manual msgfmt run. make test-unit passes in the container: 7171 passed, 9 skipped, no failures. Co-Authored-By: Claude Opus 5 (1M context) --- tests/unit/python/utils/i18n/test_translate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/python/utils/i18n/test_translate.py b/tests/unit/python/utils/i18n/test_translate.py index e47d836e26..102fff463d 100644 --- a/tests/unit/python/utils/i18n/test_translate.py +++ b/tests/unit/python/utils/i18n/test_translate.py @@ -249,9 +249,16 @@ class TestRefusalIsRemembered(unittest.TestCase): self.assertEqual( message.user_comments[2], - f"{REJECTED_PREFIX} erste Zeile\\nzweite Zeile", + f"{REJECTED_PREFIX} erste Zeile zweite Zeile", ) + def test_a_rejected_translation_carries_no_backslash(self): + _, message = self._entry() + + apply([message], [Rejected("See [test\\_file.py](../x.py)", "structure")]) + + self.assertNotIn("\\", message.user_comments[2]) + def test_a_second_rejection_replaces_the_first(self): _, message = self._entry()