From 52808a78e6baa6416030258c860c676b6a011e5d Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 11 Jan 2023 12:21:25 +0200 Subject: [PATCH] Renovate formatting in test_checkers and test_frontend --- tests/messages/test_checkers.py | 146 +++++++++-------------- tests/messages/test_frontend.py | 205 ++++++++++++++------------------ 2 files changed, 147 insertions(+), 204 deletions(-) diff --git a/tests/messages/test_checkers.py b/tests/messages/test_checkers.py index 2ae594679..3ed9a1923 100644 --- a/tests/messages/test_checkers.py +++ b/tests/messages/test_checkers.py @@ -10,9 +10,8 @@ # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. -from datetime import datetime -import time import unittest +from datetime import datetime from io import BytesIO from babel import __version__ as VERSION @@ -34,8 +33,10 @@ def test_1_num_plurals_checkers(self): except UnknownLocaleError: # Just an alias? Not what we're testing here, let's continue continue - po_file = (u"""\ -# %(english_name)s translations for TestProject. + date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale) + plural = PLURALS[_locale][0] + po_file = (f"""\ +# {locale.english_name} translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -46,14 +47,14 @@ def test_1_num_plurals_checkers(self): "Project-Id-Version: TestProject 0.1\\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\\n" "POT-Creation-Date: 2007-04-01 15:30+0200\\n" -"PO-Revision-Date: %(date)s\\n" +"PO-Revision-Date: {date}\\n" "Last-Translator: FULL NAME \\n" -"Language-Team: %(locale)s \n" -"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n" +"Language-Team: {_locale} \n" +"Plural-Forms: nplurals={plural}; plural={plural};\\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=utf-8\\n" "Content-Transfer-Encoding: 8bit\\n" -"Generated-By: Babel %(version)s\\n" +"Generated-By: Babel {VERSION}\\n" #. This will be a translator comment, #. that will include several lines @@ -66,15 +67,7 @@ def test_1_num_plurals_checkers(self): msgid_plural "foobars" msgstr[0] "" -""" % dict(locale=_locale, - english_name=locale.english_name, - version=VERSION, - year=time.strftime('%Y'), - date=format_datetime(datetime.now(LOCALTZ), - 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale=_locale), - num_plurals=PLURALS[_locale][0], - plural_expr=PLURALS[_locale][0])).encode('utf-8') +""").encode('utf-8') # This test will fail for revisions <= 406 because so far # catalog.num_plurals was neglected @@ -101,8 +94,8 @@ def test_2_num_plurals_checkers(self): except UnknownLocaleError: # Just an alias? Not what we're testing here, let's continue continue - po_file = (u"""\ -# %(english_name)s translations for TestProject. + po_file = f"""\ +# {locale.english_name} translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -113,14 +106,14 @@ def test_2_num_plurals_checkers(self): "Project-Id-Version: TestProject 0.1\\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\\n" "POT-Creation-Date: 2007-04-01 15:30+0200\\n" -"PO-Revision-Date: %(date)s\\n" +"PO-Revision-Date: {date}\\n" "Last-Translator: FULL NAME \\n" -"Language-Team: %(locale)s \\n" -"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n" +"Language-Team: {_locale} \\n" +"Plural-Forms: nplurals={num_plurals}; plural={plural_expr};\\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=utf-8\\n" "Content-Transfer-Encoding: 8bit\\n" -"Generated-By: Babel %(version)s\\n" +"Generated-By: Babel {VERSION}\\n" #. This will be a translator comment, #. that will include several lines @@ -135,13 +128,7 @@ def test_2_num_plurals_checkers(self): msgstr[1] "" msgstr[2] "" -""" % dict(locale=_locale, - english_name=locale.english_name, - version=VERSION, - year=time.strftime('%Y'), - date=date, - num_plurals=num_plurals, - plural_expr=plural_expr)).encode('utf-8') +""".encode('utf-8') # we should be adding the missing msgstr[0] # This test will fail for revisions <= 406 because so far @@ -152,8 +139,10 @@ def test_2_num_plurals_checkers(self): def test_3_num_plurals_checkers(self): for _locale in [p for p in PLURALS if PLURALS[p][0] == 3]: - po_file = (r"""\ -# %(english_name)s translations for TestProject. + plural = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale) + english_name = Locale.parse(_locale).english_name + po_file = fr"""\ +# {english_name} translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -164,14 +153,14 @@ def test_3_num_plurals_checkers(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {plural}\n" "Last-Translator: FULL NAME \n" -"Language-Team: %(locale)s \n" -"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n" +"Language-Team: {_locale} \n" +"Plural-Forms: nplurals={PLURALS[_locale][0]}; plural={PLURALS[_locale][0]};\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator comment, #. that will include several lines @@ -185,15 +174,7 @@ def test_3_num_plurals_checkers(self): msgstr[0] "" msgstr[1] "" -""" % dict(locale=_locale, - english_name=Locale.parse(_locale).english_name, - version=VERSION, - year=time.strftime('%Y'), - date=format_datetime(datetime.now(LOCALTZ), - 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale=_locale), - num_plurals=PLURALS[_locale][0], - plural_expr=PLURALS[_locale][0])).encode('utf-8') +""".encode('utf-8') # This test will fail for revisions <= 406 because so far # catalog.num_plurals was neglected @@ -203,8 +184,11 @@ def test_3_num_plurals_checkers(self): def test_4_num_plurals_checkers(self): for _locale in [p for p in PLURALS if PLURALS[p][0] == 4]: - po_file = (r"""\ -# %(english_name)s translations for TestProject. + date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale) + english_name = Locale.parse(_locale).english_name + plural = PLURALS[_locale][0] + po_file = fr"""\ +# {english_name} translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -215,14 +199,14 @@ def test_4_num_plurals_checkers(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" -"Language-Team: %(locale)s \n" -"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n" +"Language-Team: {_locale} \n" +"Plural-Forms: nplurals={plural}; plural={plural};\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator comment, #. that will include several lines @@ -237,15 +221,7 @@ def test_4_num_plurals_checkers(self): msgstr[1] "" msgstr[2] "" -""" % dict(locale=_locale, - english_name=Locale.parse(_locale).english_name, - version=VERSION, - year=time.strftime('%Y'), - date=format_datetime(datetime.now(LOCALTZ), - 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale=_locale), - num_plurals=PLURALS[_locale][0], - plural_expr=PLURALS[_locale][0])).encode('utf-8') +""".encode('utf-8') # This test will fail for revisions <= 406 because so far # catalog.num_plurals was neglected @@ -255,8 +231,11 @@ def test_4_num_plurals_checkers(self): def test_5_num_plurals_checkers(self): for _locale in [p for p in PLURALS if PLURALS[p][0] == 5]: - po_file = (r"""\ -# %(english_name)s translations for TestProject. + date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale) + english_name = Locale.parse(_locale).english_name + plural = PLURALS[_locale][0] + po_file = fr"""\ +# {english_name} translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -267,14 +246,14 @@ def test_5_num_plurals_checkers(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" -"Language-Team: %(locale)s \n" -"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n" +"Language-Team: {_locale} \n" +"Plural-Forms: nplurals={plural}; plural={plural};\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator comment, #. that will include several lines @@ -290,15 +269,7 @@ def test_5_num_plurals_checkers(self): msgstr[2] "" msgstr[3] "" -""" % dict(locale=_locale, - english_name=Locale.parse(_locale).english_name, - version=VERSION, - year=time.strftime('%Y'), - date=format_datetime(datetime.now(LOCALTZ), - 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale=_locale), - num_plurals=PLURALS[_locale][0], - plural_expr=PLURALS[_locale][0])).encode('utf-8') +""".encode('utf-8') # This test will fail for revisions <= 406 because so far # catalog.num_plurals was neglected @@ -308,8 +279,11 @@ def test_5_num_plurals_checkers(self): def test_6_num_plurals_checkers(self): for _locale in [p for p in PLURALS if PLURALS[p][0] == 6]: - po_file = (r"""\ -# %(english_name)s translations for TestProject. + english_name = Locale.parse(_locale).english_name + date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale) + plural = PLURALS[_locale][0] + po_file = fr"""\ +# {english_name} translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -320,14 +294,14 @@ def test_6_num_plurals_checkers(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" -"Language-Team: %(locale)s \n" -"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n" +"Language-Team: {_locale} \n" +"Plural-Forms: nplurals={plural}; plural={plural};\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator comment, #. that will include several lines @@ -344,15 +318,7 @@ def test_6_num_plurals_checkers(self): msgstr[3] "" msgstr[4] "" -""" % dict(locale=_locale, - english_name=Locale.parse(_locale).english_name, - version=VERSION, - year=time.strftime('%Y'), - date=format_datetime(datetime.now(LOCALTZ), - 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale=_locale), - num_plurals=PLURALS[_locale][0], - plural_expr=PLURALS[_locale][0])).encode('utf-8') +""".encode('utf-8') # This test will fail for revisions <= 406 because so far # catalog.num_plurals was neglected diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 9e3ac9f40..e91d02bf7 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -161,25 +161,26 @@ def test_extraction_with_default_mapping(self): self.assert_pot_file_exists() - expected_content = r"""# Translations template for TestProject. -# Copyright (C) %(year)s FooBar, Inc. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Translations template for TestProject. +# Copyright (C) {time.strftime('%Y')} FooBar, Inc. # This file is distributed under the same license as the TestProject # project. -# FIRST AUTHOR , %(year)s. +# FIRST AUTHOR , {time.strftime('%Y')}. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" -"POT-Creation-Date: %(date)s\n" +"POT-Creation-Date: {date}\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. TRANSLATOR: This will be a translator coment, #. that will include several lines @@ -199,10 +200,7 @@ def test_extraction_with_default_mapping(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'year': time.strftime('%Y'), - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(pot_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -220,25 +218,26 @@ def test_extraction_with_mapping_file(self): self.assert_pot_file_exists() - expected_content = r"""# Translations template for TestProject. -# Copyright (C) %(year)s FooBar, Inc. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Translations template for TestProject. +# Copyright (C) {time.strftime('%Y')} FooBar, Inc. # This file is distributed under the same license as the TestProject # project. -# FIRST AUTHOR , %(year)s. +# FIRST AUTHOR , {time.strftime('%Y')}. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" -"POT-Creation-Date: %(date)s\n" +"POT-Creation-Date: {date}\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. TRANSLATOR: This will be a translator coment, #. that will include several lines @@ -252,10 +251,7 @@ def test_extraction_with_mapping_file(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'year': time.strftime('%Y'), - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(pot_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -278,25 +274,26 @@ def test_extraction_with_mapping_dict(self): self.assert_pot_file_exists() - expected_content = r"""# Translations template for TestProject. -# Copyright (C) %(year)s FooBar, Inc. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Translations template for TestProject. +# Copyright (C) {time.strftime('%Y')} FooBar, Inc. # This file is distributed under the same license as the TestProject # project. -# FIRST AUTHOR , %(year)s. +# FIRST AUTHOR , {time.strftime('%Y')}. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" -"POT-Creation-Date: %(date)s\n" +"POT-Creation-Date: {date}\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. TRANSLATOR: This will be a translator coment, #. that will include several lines @@ -310,10 +307,7 @@ def test_extraction_with_mapping_dict(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'year': time.strftime('%Y'), - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(pot_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -396,7 +390,8 @@ def test_with_output_dir(self): po_file = _po_file('en_US') assert os.path.isfile(po_file) - expected_content = r"""# English (United States) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -407,7 +402,7 @@ def test_with_output_dir(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" "Language-Team: en_US \n" @@ -415,7 +410,7 @@ def test_with_output_dir(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -429,9 +424,7 @@ def test_with_output_dir(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -448,7 +441,8 @@ def test_keeps_catalog_non_fuzzy(self): po_file = _po_file('en_US') assert os.path.isfile(po_file) - expected_content = r"""# English (United States) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -459,7 +453,7 @@ def test_keeps_catalog_non_fuzzy(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" "Language-Team: en_US \n" @@ -467,7 +461,7 @@ def test_keeps_catalog_non_fuzzy(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -481,9 +475,7 @@ def test_keeps_catalog_non_fuzzy(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -500,7 +492,8 @@ def test_correct_init_more_than_2_plurals(self): po_file = _po_file('lv_LV') assert os.path.isfile(po_file) - expected_content = r"""# Latvian (Latvia) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Latvian (Latvia) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -511,16 +504,16 @@ def test_correct_init_more_than_2_plurals(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: lv_LV\n" "Language-Team: lv_LV \n" -"Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 :" " 2);\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -535,9 +528,7 @@ def test_correct_init_more_than_2_plurals(self): msgstr[1] "" msgstr[2] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -554,7 +545,8 @@ def test_correct_init_singular_plural_forms(self): po_file = _po_file('ja_JP') assert os.path.isfile(po_file) - expected_content = r"""# Japanese (Japan) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='ja_JP') + expected_content = fr"""# Japanese (Japan) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -565,7 +557,7 @@ def test_correct_init_singular_plural_forms(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: ja_JP\n" "Language-Team: ja_JP \n" @@ -573,7 +565,7 @@ def test_correct_init_singular_plural_forms(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -586,9 +578,7 @@ def test_correct_init_singular_plural_forms(self): msgid_plural "foobars" msgstr[0] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='ja_JP')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -613,7 +603,8 @@ def test_supports_no_wrap(self): po_file = _po_file('en_US') assert os.path.isfile(po_file) - expected_content = r"""# English (United States) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en_US') + expected_content = fr"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -624,7 +615,7 @@ def test_supports_no_wrap(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" "Language-Team: en_US \n" @@ -632,12 +623,12 @@ def test_supports_no_wrap(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines #: project/file1.py:8 -msgid %(long_message)s +msgid {long_message} msgstr "" #: project/file2.py:9 @@ -646,10 +637,7 @@ def test_supports_no_wrap(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en_US'), - 'long_message': long_message} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -673,7 +661,8 @@ def test_supports_width(self): po_file = _po_file('en_US') assert os.path.isfile(po_file) - expected_content = r"""# English (United States) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en_US') + expected_content = fr"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -684,7 +673,7 @@ def test_supports_width(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" "Language-Team: en_US \n" @@ -692,12 +681,12 @@ def test_supports_width(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines #: project/file1.py:8 -msgid %(long_message)s +msgid {long_message} msgstr "" #: project/file2.py:9 @@ -706,10 +695,7 @@ def test_supports_width(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en_US'), - 'long_message': long_message} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -823,25 +809,26 @@ def test_extract_with_default_mapping(self): '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:', '-o', pot_file, 'project']) self.assert_pot_file_exists() - expected_content = r"""# Translations template for TestProject. -# Copyright (C) %(year)s FooBar, Inc. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Translations template for TestProject. +# Copyright (C) {time.strftime('%Y')} FooBar, Inc. # This file is distributed under the same license as the TestProject # project. -# FIRST AUTHOR , %(year)s. +# FIRST AUTHOR , {time.strftime('%Y')}. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" -"POT-Creation-Date: %(date)s\n" +"POT-Creation-Date: {date}\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. TRANSLATOR: This will be a translator coment, #. that will include several lines @@ -861,10 +848,7 @@ def test_extract_with_default_mapping(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'year': time.strftime('%Y'), - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(pot_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -879,25 +863,26 @@ def test_extract_with_mapping_file(self): '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:', '-o', pot_file, 'project']) self.assert_pot_file_exists() - expected_content = r"""# Translations template for TestProject. -# Copyright (C) %(year)s FooBar, Inc. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Translations template for TestProject. +# Copyright (C) {time.strftime('%Y')} FooBar, Inc. # This file is distributed under the same license as the TestProject # project. -# FIRST AUTHOR , %(year)s. +# FIRST AUTHOR , {time.strftime('%Y')}. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" -"POT-Creation-Date: %(date)s\n" +"POT-Creation-Date: {date}\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. TRANSLATOR: This will be a translator coment, #. that will include several lines @@ -911,10 +896,7 @@ def test_extract_with_mapping_file(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'year': time.strftime('%Y'), - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(pot_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -933,25 +915,26 @@ def test_extract_with_exact_file(self): '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:', '-o', pot_file, file_to_extract]) self.assert_pot_file_exists() - expected_content = r"""# Translations template for TestProject. -# Copyright (C) %(year)s FooBar, Inc. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Translations template for TestProject. +# Copyright (C) {time.strftime('%Y')} FooBar, Inc. # This file is distributed under the same license as the TestProject # project. -# FIRST AUTHOR , %(year)s. +# FIRST AUTHOR , {time.strftime('%Y')}. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" -"POT-Creation-Date: %(date)s\n" +"POT-Creation-Date: {date}\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #: project/file2.py:9 msgid "foobar" @@ -959,10 +942,7 @@ def test_extract_with_exact_file(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'year': time.strftime('%Y'), - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(pot_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -975,7 +955,8 @@ def test_init_with_output_dir(self): '-d', os.path.join(i18n_dir), '-i', os.path.join(i18n_dir, 'messages.pot')]) assert os.path.isfile(po_file) - expected_content = r"""# English (United States) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -986,7 +967,7 @@ def test_init_with_output_dir(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" "Language-Team: en_US \n" @@ -994,7 +975,7 @@ def test_init_with_output_dir(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -1008,9 +989,7 @@ def test_init_with_output_dir(self): msgstr[0] "" msgstr[1] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -1023,7 +1002,8 @@ def test_init_singular_plural_forms(self): '-d', os.path.join(i18n_dir), '-i', os.path.join(i18n_dir, 'messages.pot')]) assert os.path.isfile(po_file) - expected_content = r"""# Japanese (Japan) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Japanese (Japan) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -1034,7 +1014,7 @@ def test_init_singular_plural_forms(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: ja_JP\n" "Language-Team: ja_JP \n" @@ -1042,7 +1022,7 @@ def test_init_singular_plural_forms(self): "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -1055,9 +1035,7 @@ def test_init_singular_plural_forms(self): msgid_plural "foobars" msgstr[0] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content @@ -1070,7 +1048,8 @@ def test_init_more_than_2_plural_forms(self): '-d', i18n_dir, '-i', os.path.join(i18n_dir, 'messages.pot')]) assert os.path.isfile(po_file) - expected_content = r"""# Latvian (Latvia) translations for TestProject. + date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en') + expected_content = fr"""# Latvian (Latvia) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -1081,16 +1060,16 @@ def test_init_more_than_2_plural_forms(self): "Project-Id-Version: TestProject 0.1\n" "Report-Msgid-Bugs-To: bugs.address@email.tld\n" "POT-Creation-Date: 2007-04-01 15:30+0200\n" -"PO-Revision-Date: %(date)s\n" +"PO-Revision-Date: {date}\n" "Last-Translator: FULL NAME \n" "Language: lv_LV\n" "Language-Team: lv_LV \n" -"Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 :" " 2);\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel %(version)s\n" +"Generated-By: Babel {VERSION}\n" #. This will be a translator coment, #. that will include several lines @@ -1105,9 +1084,7 @@ def test_init_more_than_2_plural_forms(self): msgstr[1] "" msgstr[2] "" -""" % {'version': VERSION, - 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')} +""" with open(po_file) as f: actual_content = f.read() assert expected_content == actual_content