summaryrefslogtreecommitdiff
path: root/tests/messages/test_checkers.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/messages/test_checkers.py')
-rw-r--r--tests/messages/test_checkers.py146
1 files changed, 56 insertions, 90 deletions
diff --git a/tests/messages/test_checkers.py b/tests/messages/test_checkers.py
index 2ae5946..3ed9a19 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 @@ class CheckersTestCase(unittest.TestCase):
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 @@ msgstr ""
"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 <EMAIL@ADDRESS>\\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n"
+"Language-Team: {_locale} <LL@li.org>\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 @@ msgid "foobar"
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 @@ msgstr[0] ""
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 @@ msgstr ""
"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 <EMAIL@ADDRESS>\\n"
-"Language-Team: %(locale)s <LL@li.org>\\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n"
+"Language-Team: {_locale} <LL@li.org>\\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 @@ msgstr[0] ""
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 @@ msgstr[2] ""
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 @@ msgstr ""
"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 <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\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 @@ msgid_plural "foobars"
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 @@ msgstr[1] ""
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 @@ msgstr ""
"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 <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\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 @@ msgstr[0] ""
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 @@ msgstr[2] ""
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 @@ msgstr ""
"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 <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\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 @@ msgstr[1] ""
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 @@ msgstr[3] ""
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 @@ msgstr ""
"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 <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\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 @@ msgstr[2] ""
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