1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #33476 -- Refactored code to strictly match 88 characters line length.

This commit is contained in:
Mariusz Felisiak
2022-02-04 08:08:27 +01:00
parent 9c19aff7c7
commit 7119f40c98
404 changed files with 5944 additions and 2842 deletions

View File

@@ -436,9 +436,13 @@ class URLTagTests(URLTestCaseBase):
def test_args(self):
tpl = Template(
"""{% load i18n %}
{% language 'nl' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}
{% language 'pt-br' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}"""
"""
{% load i18n %}
{% language 'nl' %}
{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}
{% language 'pt-br' %}
{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}
"""
)
self.assertEqual(
tpl.render(Context({})).strip().split(),
@@ -447,9 +451,13 @@ class URLTagTests(URLTestCaseBase):
def test_kwargs(self):
tpl = Template(
"""{% load i18n %}
{% language 'nl' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}
{% language 'pt-br' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}"""
"""
{% load i18n %}
{% language 'nl' %}
{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}
{% language 'pt-br' %}
{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}
"""
)
self.assertEqual(
tpl.render(Context({})).strip().split(),

View File

@@ -108,7 +108,8 @@ class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase):
r"""
self.assertLocationCommentPresent('django.po', 42, 'dirA', 'dirB', 'foo.py')
verifies that the django.po file has a gettext-style location comment of the form
verifies that the django.po file has a gettext-style location comment
of the form
`#: dirA/dirB/foo.py:42`
@@ -128,14 +129,16 @@ class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase):
def assertRecentlyModified(self, path):
"""
Assert that file was recently modified (modification time was less than 10 seconds ago).
Assert that file was recently modified (modification time was less than
10 seconds ago).
"""
delta = time.time() - os.stat(path).st_mtime
self.assertLess(delta, 10, "%s was recently modified" % path)
def assertNotRecentlyModified(self, path):
"""
Assert that file was not recently modified (modification time was more than 10 seconds ago).
Assert that file was not recently modified (modification time was more
than 10 seconds ago).
"""
delta = time.time() - os.stat(path).st_mtime
self.assertGreater(delta, 10, "%s wasn't recently modified" % path)
@@ -443,7 +446,8 @@ class BasicExtractorTests(ExtractorTests):
mocked_popen_wrapper.return_value = (
"xgettext (GNU gettext-tools) 0.18.1\n"
"Copyright (C) 1995-1998, 2000-2010 Free Software Foundation, Inc.\n"
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
"License GPLv3+: GNU GPL version 3 or later "
"<http://gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"
"Written by Ulrich Drepper.\n",
@@ -773,7 +777,10 @@ class LocationCommentsTests(ExtractorTests):
CommandError is raised when using makemessages --add-location with
gettext < 0.19.
"""
msg = "The --add-location option requires gettext 0.19 or later. You have 0.18.99."
msg = (
"The --add-location option requires gettext 0.19 or later. You have "
"0.18.99."
)
with self.assertRaisesMessage(CommandError, msg):
management.call_command(
"makemessages", locale=[LOCALE], verbosity=0, add_location="full"

View File

@@ -87,7 +87,8 @@ class RenderingTemplatesWithPercentSigns(FrenchTestCase):
expected = "Littérale avec un symbole de pour cent à la fin %"
trans_tpl = Template(
'{% load i18n %}{% translate "Literal with a percent symbol at the end %" %}'
"{% load i18n %}"
'{% translate "Literal with a percent symbol at the end %" %}'
)
self.assertEqual(trans_tpl.render(Context({})), expected)
@@ -101,7 +102,8 @@ class RenderingTemplatesWithPercentSigns(FrenchTestCase):
expected = "Pour cent littérale % avec un symbole au milieu"
trans_tpl = Template(
'{% load i18n %}{% translate "Literal with a percent % symbol in the middle" %}'
"{% load i18n %}"
'{% translate "Literal with a percent % symbol in the middle" %}'
)
self.assertEqual(trans_tpl.render(Context({})), expected)
@@ -124,13 +126,17 @@ class RenderingTemplatesWithPercentSigns(FrenchTestCase):
)
self.assertEqual(block_tpl.render(Context({})), "Il est de 100%")
block_tpl = Template(
'{% load i18n %}{% blocktranslate context "female" %}It is 100%{% endblocktranslate %}'
"{% load i18n %}"
'{% blocktranslate context "female" %}It is 100%{% endblocktranslate %}'
)
self.assertEqual(block_tpl.render(Context({})), "Elle est de 100%")
def test_translates_with_string_that_look_like_fmt_spec_with_trans(self):
# tests "%s"
expected = "On dirait un spec str fmt %s mais ne devrait pas être interprété comme plus disponible"
expected = (
"On dirait un spec str fmt %s mais ne devrait pas être interprété comme "
"plus disponible"
)
trans_tpl = Template(
'{% load i18n %}{% translate "Looks like a str fmt spec %s but '
'should not be interpreted as such" %}'
@@ -143,21 +149,28 @@ class RenderingTemplatesWithPercentSigns(FrenchTestCase):
self.assertEqual(block_tpl.render(Context({})), expected)
# tests "% o"
expected = "On dirait un spec str fmt % o mais ne devrait pas être interprété comme plus disponible"
expected = (
"On dirait un spec str fmt % o mais ne devrait pas être interprété comme "
"plus disponible"
)
trans_tpl = Template(
'{% load i18n %}{% translate "Looks like a str fmt spec % o but should not be '
"{% load i18n %}"
'{% translate "Looks like a str fmt spec % o but should not be '
'interpreted as such" %}'
)
self.assertEqual(trans_tpl.render(Context({})), expected)
block_tpl = Template(
"{% load i18n %}{% blocktranslate %}Looks like a str fmt spec % o but should not be "
"{% load i18n %}"
"{% blocktranslate %}Looks like a str fmt spec % o but should not be "
"interpreted as such{% endblocktranslate %}"
)
self.assertEqual(block_tpl.render(Context({})), expected)
def test_translates_multiple_percent_signs(self):
expected = "1 % signe pour cent, signes %% 2 pour cent, trois signes de pourcentage %%%"
expected = (
"1 % signe pour cent, signes %% 2 pour cent, trois signes de pourcentage "
"%%%"
)
trans_tpl = Template(
'{% load i18n %}{% translate "1 percent sign %, 2 percent signs %%, '
'3 percent signs %%%" %}'

View File

@@ -648,7 +648,8 @@ class FormattingTests(SimpleTestCase):
thousand_sep=",",
),
)
# This unusual grouping/force_grouping combination may be triggered by the intcomma filter (#17414)
# This unusual grouping/force_grouping combination may be triggered
# by the intcomma filter.
self.assertEqual(
"10000",
nformat(
@@ -1119,10 +1120,12 @@ class FormattingTests(SimpleTestCase):
'<option value="6">\u0418\u044e\u043d\u044c</option>'
'<option value="7">\u0418\u044e\u043b\u044c</option>'
'<option value="8">\u0410\u0432\u0433\u0443\u0441\u0442</option>'
'<option value="9">\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c</option>'
'<option value="9">\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c'
"</option>"
'<option value="10">\u041e\u043a\u0442\u044f\u0431\u0440\u044c</option>'
'<option value="11">\u041d\u043e\u044f\u0431\u0440\u044c</option>'
'<option value="12" selected>\u0414\u0435\u043a\u0430\u0431\u0440\u044c</option>'
'<option value="12" selected>\u0414\u0435\u043a\u0430\u0431\u0440\u044c'
"</option>"
"</select>"
'<select name="mydate_year" id="id_mydate_year">'
'<option value="">---</option>'
@@ -1333,13 +1336,17 @@ class FormattingTests(SimpleTestCase):
self.assertHTMLEqual(
form6.as_ul(),
'<li><label for="id_name">Name:</label>'
'<input id="id_name" type="text" name="name" value="acme" maxlength="50" required></li>'
'<input id="id_name" type="text" name="name" value="acme" '
' maxlength="50" required></li>'
'<li><label for="id_date_added">Date added:</label>'
'<input type="text" name="date_added" value="31.12.2009 06:00:00" id="id_date_added" required></li>'
'<input type="text" name="date_added" value="31.12.2009 06:00:00" '
' id="id_date_added" required></li>'
'<li><label for="id_cents_paid">Cents paid:</label>'
'<input type="text" name="cents_paid" value="59,47" id="id_cents_paid" required></li>'
'<input type="text" name="cents_paid" value="59,47" id="id_cents_paid" '
" required></li>"
'<li><label for="id_products_delivered">Products delivered:</label>'
'<input type="text" name="products_delivered" value="12000" id="id_products_delivered" required>'
'<input type="text" name="products_delivered" value="12000" '
' id="id_products_delivered" required>'
"</li>",
)
self.assertEqual(
@@ -1516,7 +1523,8 @@ class FormattingTests(SimpleTestCase):
{"int": 1455, "float": 3.14, "date": datetime.date(2016, 12, 31)}
)
template1 = Template(
"{% load l10n %}{% localize %}{{ int }}/{{ float }}/{{ date }}{% endlocalize %}; "
"{% load l10n %}{% localize %}"
"{{ int }}/{{ float }}/{{ date }}{% endlocalize %}; "
"{% localize on %}{{ int }}/{{ float }}/{{ date }}{% endlocalize %}"
)
template2 = Template(
@@ -1589,7 +1597,7 @@ class FormattingTests(SimpleTestCase):
def test_localized_as_text_as_hidden_input(self):
"""
Tests if form input with 'as_hidden' or 'as_text' is correctly localized. Ticket #18777
Form input with 'as_hidden' or 'as_text' is correctly localized.
"""
self.maxDiff = 1200
@@ -1598,10 +1606,12 @@ class FormattingTests(SimpleTestCase):
"{% load l10n %}{{ form.date_added }}; {{ form.cents_paid }}"
)
template_as_text = Template(
"{% load l10n %}{{ form.date_added.as_text }}; {{ form.cents_paid.as_text }}"
"{% load l10n %}"
"{{ form.date_added.as_text }}; {{ form.cents_paid.as_text }}"
)
template_as_hidden = Template(
"{% load l10n %}{{ form.date_added.as_hidden }}; {{ form.cents_paid.as_hidden }}"
"{% load l10n %}"
"{{ form.date_added.as_hidden }}; {{ form.cents_paid.as_hidden }}"
)
form = CompanyForm(
{
@@ -1616,18 +1626,24 @@ class FormattingTests(SimpleTestCase):
self.assertHTMLEqual(
template.render(context),
'<input id="id_date_added" name="date_added" type="text" value="31.12.2009 06:00:00" required>;'
'<input id="id_cents_paid" name="cents_paid" type="text" value="59,47" required>',
'<input id="id_date_added" name="date_added" type="text" '
'value="31.12.2009 06:00:00" required>;'
'<input id="id_cents_paid" name="cents_paid" type="text" value="59,47" '
"required>",
)
self.assertHTMLEqual(
template_as_text.render(context),
'<input id="id_date_added" name="date_added" type="text" value="31.12.2009 06:00:00" required>;'
' <input id="id_cents_paid" name="cents_paid" type="text" value="59,47" required>',
'<input id="id_date_added" name="date_added" type="text" '
'value="31.12.2009 06:00:00" required>;'
'<input id="id_cents_paid" name="cents_paid" type="text" value="59,47" '
"required>",
)
self.assertHTMLEqual(
template_as_hidden.render(context),
'<input id="id_date_added" name="date_added" type="hidden" value="31.12.2009 06:00:00">;'
'<input id="id_cents_paid" name="cents_paid" type="hidden" value="59,47">',
'<input id="id_date_added" name="date_added" type="hidden" '
'value="31.12.2009 06:00:00">;'
'<input id="id_cents_paid" name="cents_paid" type="hidden" '
'value="59,47">',
)
def test_format_arbitrary_settings(self):
@@ -1999,8 +2015,8 @@ class ResolutionOrderI18NTests(SimpleTestCase):
self.assertIn(
msgstr,
result,
"The string '%s' isn't in the translation of '%s'; the actual result is '%s'."
% (msgstr, msgid, result),
"The string '%s' isn't in the translation of '%s'; the actual result is "
"'%s'." % (msgstr, msgid, result),
)