Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renovate formatting in test_checkers and test_frontend #950

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 56 additions & 90 deletions tests/messages/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -46,14 +47,14 @@ def test_1_num_plurals_checkers(self):
"Project-Id-Version: TestProject 0.1\\n"
"Report-Msgid-Bugs-To: [email protected]\\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 <[email protected]>\n"
"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n"
"Language-Team: {_locale} <[email protected]>\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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -113,14 +106,14 @@ def test_2_num_plurals_checkers(self):
"Project-Id-Version: TestProject 0.1\\n"
"Report-Msgid-Bugs-To: [email protected]\\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 <[email protected]>\\n"
"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n"
"Language-Team: {_locale} <[email protected]>\\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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -164,14 +153,14 @@ def test_3_num_plurals_checkers(self):
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
"Language-Team: {_locale} <[email protected]>\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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -215,14 +199,14 @@ def test_4_num_plurals_checkers(self):
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
"Language-Team: {_locale} <[email protected]>\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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -267,14 +246,14 @@ def test_5_num_plurals_checkers(self):
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
"Language-Team: {_locale} <[email protected]>\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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -320,14 +294,14 @@ def test_6_num_plurals_checkers(self):
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: [email protected]\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 <[email protected]>\n"
"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
"Language-Team: {_locale} <[email protected]>\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
Expand All @@ -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
Expand Down
Loading