From c9dfd5c14e7347950d8d526f6ba2d8ea6f5fd6d7 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sat, 3 Sep 2022 03:10:07 +0200 Subject: [PATCH] Add more comments tests for keyword spec --- tests/comments_test.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/comments_test.py b/tests/comments_test.py index 04663f4..59965b7 100644 --- a/tests/comments_test.py +++ b/tests/comments_test.py @@ -3,7 +3,7 @@ from redgettext import Options from tests.utils import FILENAME, get_extractor, get_test_potfile -OPTIONS = Options() +OPTIONS = Options(keyword_specs=("_:1", 'ngettext:1,2,"comment from keyword spec"')) SOURCE = """\ # Translators: comment A1 _('A') + _('B') @@ -41,6 +41,12 @@ # as long as there's no code between _('D') + +# Translators: handles comments from keyspec too +# no matter if there's a translator comment in code or not +ngettext('E', 'F', 2) + +ngettext('G', 'H', 2) """ @@ -86,6 +92,22 @@ def test_comments() -> None: "as long as there's no code between" ), ), + polib.POEntry( + msgid="E", + msgid_plural="F", + occurrences=[(FILENAME, 40)], + comment=( + "Translators: handles comments from keyspec too\n" + "no matter if there's a translator comment in code or not\n" + "comment from keyword spec" + ), + ), + polib.POEntry( + msgid="G", + msgid_plural="H", + occurrences=[(FILENAME, 42)], + comment="comment from keyword spec", + ), ) assert str(extractor.potfile_manager.current_potfile) == str(expected) assert extractor.potfile_manager.current_potfile == expected