diff --git a/tests/unit/python/utils/i18n/test_repairs.py b/tests/unit/python/utils/i18n/test_repairs.py index a7e4fcd525..d3e649b3e2 100644 --- a/tests/unit/python/utils/i18n/test_repairs.py +++ b/tests/unit/python/utils/i18n/test_repairs.py @@ -8,7 +8,6 @@ lower-cased, and a run of spaces it opened around a span. from __future__ import annotations import unittest - from typing import ClassVar from utils.i18n.placeholders import ( @@ -18,6 +17,7 @@ from utils.i18n.placeholders import ( recapitalise, resegment, terminate, + tighten, truncated, unmask, ) @@ -176,6 +176,25 @@ class TestWriterAndGateAgree(unittest.TestCase): self.assertFalse(harms(self.SOURCE, faithful)) self.assertEqual(_round_trip(self.SOURCE, faithful), faithful) + def test_prune_can_clear_what_the_repository_lint_reports(self) -> None: + source = "**bold** text here and more words to say" + spaced = "** fett ** Text hier und mehr Worte zu sagen" + + self.assertNotEqual(tighten(spaced), spaced, "the lint would report this") + self.assertTrue(harms(source, spaced), "so damaged() must report it too") + + def test_a_repaired_translation_is_not_reported_by_the_widened_predicate( + self, + ) -> None: + source = "All `alpha` criteria." + restored = _round_trip(source, 'alle Kriterien') + + self.assertEqual(restored, "Alle `alpha` Kriterien.") + self.assertFalse( + harms(source, restored), + "the repairs run before harms(), so a written entry must stay clean", + ) + def test_every_criterion_of_the_gate_reaches_the_client(self) -> None: named = "Deploy web-app-docs before the documentation site answers anything." for label, source, translation in ( diff --git a/utils/i18n/placeholders.py b/utils/i18n/placeholders.py index ab6bed4ebd..ba50597935 100644 --- a/utils/i18n/placeholders.py +++ b/utils/i18n/placeholders.py @@ -249,6 +249,8 @@ def harms(source: str, translation: str) -> bool: or missing_names(source, translation) or truncated(source, translation) or structure(translation) != structure(source) + or tighten(translation) != translation + or resegment(translation, mask(source).spans, source) != translation )