summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /tests/template_tests/syntax_tests
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/template_tests/syntax_tests')
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_blocktranslate.py184
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_get_available_languages.py5
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_get_current_language.py5
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_get_current_language_bidi.py5
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_get_language_info_list.py5
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_translate.py31
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_underscore_syntax.py5
-rw-r--r--tests/template_tests/syntax_tests/test_autoescape.py18
-rw-r--r--tests/template_tests/syntax_tests/test_cache.py18
-rw-r--r--tests/template_tests/syntax_tests/test_cycle.py22
-rw-r--r--tests/template_tests/syntax_tests/test_exceptions.py8
-rw-r--r--tests/template_tests/syntax_tests/test_extends.py49
-rw-r--r--tests/template_tests/syntax_tests/test_for.py65
-rw-r--r--tests/template_tests/syntax_tests/test_if.py32
-rw-r--r--tests/template_tests/syntax_tests/test_if_changed.py53
-rw-r--r--tests/template_tests/syntax_tests/test_include.py17
-rw-r--r--tests/template_tests/syntax_tests/test_invalid_string.py4
-rw-r--r--tests/template_tests/syntax_tests/test_load.py24
-rw-r--r--tests/template_tests/syntax_tests/test_named_endblock.py4
-rw-r--r--tests/template_tests/syntax_tests/test_resetcycle.py4
-rw-r--r--tests/template_tests/syntax_tests/test_spaceless.py16
-rw-r--r--tests/template_tests/syntax_tests/test_static.py13
-rw-r--r--tests/template_tests/syntax_tests/test_verbatim.py8
23 files changed, 438 insertions, 157 deletions
diff --git a/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py b/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py
index 8ad004a899..4a162362c6 100644
--- a/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py
+++ b/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py
@@ -52,7 +52,9 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n03": "{% load i18n %}{% blocktranslate %}{{ anton }}{% endblocktranslate %}"
+ "i18n03": (
+ "{% load i18n %}{% blocktranslate %}{{ anton }}{% endblocktranslate %}"
+ )
}
)
def test_i18n03(self):
@@ -62,7 +64,10 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n04": "{% load i18n %}{% blocktranslate with berta=anton|lower %}{{ berta }}{% endblocktranslate %}"
+ "i18n04": (
+ "{% load i18n %}{% blocktranslate with berta=anton|lower %}{{ berta }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n04(self):
@@ -72,8 +77,11 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "legacyi18n04": "{% load i18n %}"
- "{% blocktranslate with anton|lower as berta %}{{ berta }}{% endblocktranslate %}"
+ "legacyi18n04": (
+ "{% load i18n %}"
+ "{% blocktranslate with anton|lower as berta %}{{ berta }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_legacyi18n04(self):
@@ -83,7 +91,10 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n05": "{% load i18n %}{% blocktranslate %}xxx{{ anton }}xxx{% endblocktranslate %}"
+ "i18n05": (
+ "{% load i18n %}{% blocktranslate %}xxx{{ anton }}xxx"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n05(self):
@@ -141,8 +152,11 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n17": "{% load i18n %}"
- "{% blocktranslate with berta=anton|escape %}{{ berta }}{% endblocktranslate %}"
+ "i18n17": (
+ "{% load i18n %}"
+ "{% blocktranslate with berta=anton|escape %}{{ berta }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n17(self):
@@ -155,8 +169,11 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n18": "{% load i18n %}"
- "{% blocktranslate with berta=anton|force_escape %}{{ berta }}{% endblocktranslate %}"
+ "i18n18": (
+ "{% load i18n %}"
+ "{% blocktranslate with berta=anton|force_escape %}{{ berta }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n18(self):
@@ -165,7 +182,9 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n19": "{% load i18n %}{% blocktranslate %}{{ andrew }}{% endblocktranslate %}"
+ "i18n19": (
+ "{% load i18n %}{% blocktranslate %}{{ andrew }}{% endblocktranslate %}"
+ )
}
)
def test_i18n19(self):
@@ -174,7 +193,9 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n21": "{% load i18n %}{% blocktranslate %}{{ andrew }}{% endblocktranslate %}"
+ "i18n21": (
+ "{% load i18n %}{% blocktranslate %}{{ andrew }}{% endblocktranslate %}"
+ )
}
)
def test_i18n21(self):
@@ -183,8 +204,11 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "legacyi18n17": "{% load i18n %}"
- "{% blocktranslate with anton|escape as berta %}{{ berta }}{% endblocktranslate %}"
+ "legacyi18n17": (
+ "{% load i18n %}"
+ "{% blocktranslate with anton|escape as berta %}{{ berta }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_legacyi18n17(self):
@@ -220,9 +244,12 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "legacyi18n26": "{% load i18n %}"
- "{% blocktranslate with myextra_field as extra_field count number as counter %}"
- "singular {{ extra_field }}{% plural %}plural{% endblocktranslate %}"
+ "legacyi18n26": (
+ "{% load i18n %}"
+ "{% blocktranslate with myextra_field as extra_field "
+ "count number as counter %}singular {{ extra_field }}{% plural %}plural"
+ "{% endblocktranslate %}"
+ )
}
)
def test_legacyi18n26(self):
@@ -262,8 +289,11 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n28": "{% load i18n %}"
- "{% blocktranslate with a=anton b=berta %}{{ a }} + {{ b }}{% endblocktranslate %}"
+ "i18n28": (
+ "{% load i18n %}"
+ "{% blocktranslate with a=anton b=berta %}{{ a }} + {{ b }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n28(self):
@@ -288,7 +318,10 @@ class I18nBlockTransTagTests(SimpleTestCase):
# this should work as if blocktranslate was not there (#19915)
@setup(
{
- "i18n34": "{% load i18n %}{% blocktranslate %}{{ missing }}{% endblocktranslate %}"
+ "i18n34": (
+ "{% load i18n %}{% blocktranslate %}{{ missing }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n34(self):
@@ -300,7 +333,10 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n34_2": "{% load i18n %}{% blocktranslate with a='α' %}{{ missing }}{% endblocktranslate %}"
+ "i18n34_2": (
+ "{% load i18n %}{% blocktranslate with a='α' %}{{ missing }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n34_2(self):
@@ -312,7 +348,10 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "i18n34_3": "{% load i18n %}{% blocktranslate with a=anton %}{{ missing }}{% endblocktranslate %}"
+ "i18n34_3": (
+ "{% load i18n %}{% blocktranslate with a=anton %}{{ missing }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_i18n34_3(self):
@@ -337,9 +376,11 @@ class I18nBlockTransTagTests(SimpleTestCase):
# blocktranslate tag with asvar
@setup(
{
- "i18n39": "{% load i18n %}"
- "{% blocktranslate asvar page_not_found %}Page not found{% endblocktranslate %}"
- ">{{ page_not_found }}<"
+ "i18n39": (
+ "{% load i18n %}"
+ "{% blocktranslate asvar page_not_found %}Page not found"
+ "{% endblocktranslate %}>{{ page_not_found }}<"
+ )
}
)
def test_i18n39(self):
@@ -377,7 +418,9 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "template": "{% load i18n %}{% blocktranslate asvar %}Yes{% endblocktranslate %}"
+ "template": (
+ "{% load i18n %}{% blocktranslate asvar %}Yes{% endblocktranslate %}"
+ )
}
)
def test_blocktrans_syntax_error_missing_assignment(self, tag_name):
@@ -394,7 +437,10 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "template": "{% load i18n %}{% blocktranslate %}{% block b %} {% endblock %}{% endblocktranslate %}"
+ "template": (
+ "{% load i18n %}{% blocktranslate %}{% block b %} {% endblock %}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_with_block(self, tag_name):
@@ -414,15 +460,19 @@ class I18nBlockTransTagTests(SimpleTestCase):
}
)
def test_with_for(self, tag_name):
- msg = "'{}' doesn't allow other block tags (seen 'for b in [1, 2, 3]') inside it".format(
- tag_name
+ msg = (
+ f"'{tag_name}' doesn't allow other block tags (seen 'for b in [1, 2, 3]') "
+ f"inside it"
)
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("template")
@setup(
{
- "template": "{% load i18n %}{% blocktranslate with foo=bar with %}{{ foo }}{% endblocktranslate %}"
+ "template": (
+ "{% load i18n %}{% blocktranslate with foo=bar with %}{{ foo }}"
+ "{% endblocktranslate %}"
+ )
}
)
def test_variable_twice(self):
@@ -443,7 +493,9 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup(
{
- "template": "{% load i18n %}{% blocktranslate count a %}{% endblocktranslate %}"
+ "template": (
+ "{% load i18n %}{% blocktranslate count a %}{% endblocktranslate %}"
+ )
}
)
def test_count(self, tag_name):
@@ -509,12 +561,14 @@ class TranslationBlockTranslateTagTests(SimpleTestCase):
# Existing context... using a literal
t = self.get_template(
- '{% load i18n %}{% blocktranslate context "month name" %}May{% endblocktranslate %}'
+ "{% load i18n %}"
+ '{% blocktranslate context "month name" %}May{% endblocktranslate %}'
)
rendered = t.render(Context())
self.assertEqual(rendered, "Mai")
t = self.get_template(
- '{% load i18n %}{% blocktranslate context "verb" %}May{% endblocktranslate %}'
+ "{% load i18n %}"
+ '{% blocktranslate context "verb" %}May{% endblocktranslate %}'
)
rendered = t.render(Context())
self.assertEqual(rendered, "Kann")
@@ -535,51 +589,65 @@ class TranslationBlockTranslateTagTests(SimpleTestCase):
# Using a filter
t = self.get_template(
- "{% load i18n %}{% blocktranslate context message_context|lower %}May{% endblocktranslate %}"
+ "{% load i18n %}"
+ "{% blocktranslate context message_context|lower %}May"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context({"message_context": "MONTH NAME"}))
self.assertEqual(rendered, "Mai")
t = self.get_template(
- "{% load i18n %}{% blocktranslate context message_context|lower %}May{% endblocktranslate %}"
+ "{% load i18n %}"
+ "{% blocktranslate context message_context|lower %}May"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context({"message_context": "VERB"}))
self.assertEqual(rendered, "Kann")
# Using 'count'
t = self.get_template(
- '{% load i18n %}{% blocktranslate count number=1 context "super search" %}'
- "{{ number }} super result{% plural %}{{ number }} super results{% endblocktranslate %}"
+ "{% load i18n %}"
+ '{% blocktranslate count number=1 context "super search" %}{{ number }}'
+ " super result{% plural %}{{ number }} super results"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "1 Super-Ergebnis")
t = self.get_template(
- '{% load i18n %}{% blocktranslate count number=2 context "super search" %}{{ number }}'
- " super result{% plural %}{{ number }} super results{% endblocktranslate %}"
+ "{% load i18n %}"
+ '{% blocktranslate count number=2 context "super search" %}{{ number }}'
+ " super result{% plural %}{{ number }} super results"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "2 Super-Ergebnisse")
t = self.get_template(
- '{% load i18n %}{% blocktranslate context "other super search" count number=1 %}'
- "{{ number }} super result{% plural %}{{ number }} super results{% endblocktranslate %}"
+ "{% load i18n %}"
+ '{% blocktranslate context "other super search" count number=1 %}'
+ "{{ number }} super result{% plural %}{{ number }} super results"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "1 anderen Super-Ergebnis")
t = self.get_template(
- '{% load i18n %}{% blocktranslate context "other super search" count number=2 %}'
- "{{ number }} super result{% plural %}{{ number }} super results{% endblocktranslate %}"
+ "{% load i18n %}"
+ '{% blocktranslate context "other super search" count number=2 %}'
+ "{{ number }} super result{% plural %}{{ number }} super results"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "2 andere Super-Ergebnisse")
# Using 'with'
t = self.get_template(
- '{% load i18n %}{% blocktranslate with num_comments=5 context "comment count" %}'
+ "{% load i18n %}"
+ '{% blocktranslate with num_comments=5 context "comment count" %}'
"There are {{ num_comments }} comments{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "Es gibt 5 Kommentare")
t = self.get_template(
- '{% load i18n %}{% blocktranslate with num_comments=5 context "other comment count" %}'
+ "{% load i18n %}"
+ '{% blocktranslate with num_comments=5 context "other comment count" %}'
"There are {{ num_comments }} comments{% endblocktranslate %}"
)
rendered = t.render(Context())
@@ -593,14 +661,19 @@ class TranslationBlockTranslateTagTests(SimpleTestCase):
rendered = t.render(Context())
self.assertEqual(rendered, "There are 5 comments")
t = self.get_template(
- '{% load i18n %}{% blocktranslate with num_comments=5 context "comment count" trimmed %}\n\n'
- "There are \t\n \t {{ num_comments }} comments\n\n{% endblocktranslate %}"
+ "{% load i18n %}"
+ '{% blocktranslate with num_comments=5 context "comment count" trimmed '
+ "%}\n\n"
+ "There are \t\n \t {{ num_comments }} comments\n\n"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "Es gibt 5 Kommentare")
t = self.get_template(
- '{% load i18n %}{% blocktranslate context "other super search" count number=2 trimmed %}\n'
- "{{ number }} super \n result{% plural %}{{ number }} super results{% endblocktranslate %}"
+ "{% load i18n %}"
+ '{% blocktranslate context "other super search" count number=2 trimmed '
+ "%}\n{{ number }} super \n result{% plural %}{{ number }} super results"
+ "{% endblocktranslate %}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "2 andere Super-Ergebnisse")
@@ -609,7 +682,8 @@ class TranslationBlockTranslateTagTests(SimpleTestCase):
msg = "Unknown argument for 'blocktranslate' tag: %r."
with self.assertRaisesMessage(TemplateSyntaxError, msg % 'month="May"'):
self.get_template(
- '{% load i18n %}{% blocktranslate context with month="May" %}{{ month }}{% endblocktranslate %}'
+ '{% load i18n %}{% blocktranslate context with month="May" %}'
+ "{{ month }}{% endblocktranslate %}"
)
msg = (
'"context" in %r tag expected exactly one argument.' % "blocktranslate"
@@ -633,7 +707,8 @@ class TranslationBlockTranslateTagTests(SimpleTestCase):
"""
with translation.override("fr"):
t = Template(
- "{% load i18n %}{% blocktranslate %}My name is {{ person }}.{% endblocktranslate %}"
+ "{% load i18n %}{% blocktranslate %}My name is {{ person }}."
+ "{% endblocktranslate %}"
)
rendered = t.render(Context({"person": "James"}))
self.assertEqual(rendered, "My name is James.")
@@ -647,7 +722,8 @@ class TranslationBlockTranslateTagTests(SimpleTestCase):
"""
with translation.override("fr"):
t = Template(
- "{% load i18n %}{% blocktranslate %}My other name is {{ person }}.{% endblocktranslate %}"
+ "{% load i18n %}{% blocktranslate %}My other name is {{ person }}."
+ "{% endblocktranslate %}"
)
rendered = t.render(Context({"person": "James"}))
self.assertEqual(rendered, "My other name is James.")
@@ -728,7 +804,8 @@ class MiscTests(SimpleTestCase):
@override_settings(LOCALE_PATHS=extended_locale_paths)
def test_percent_in_translatable_block(self):
t_sing = self.get_template(
- "{% load i18n %}{% blocktranslate %}The result was {{ percent }}%{% endblocktranslate %}"
+ "{% load i18n %}{% blocktranslate %}The result was {{ percent }}%"
+ "{% endblocktranslate %}"
)
t_plur = self.get_template(
"{% load i18n %}{% blocktranslate count num as number %}"
@@ -755,7 +832,8 @@ class MiscTests(SimpleTestCase):
or plural.
"""
t_sing = self.get_template(
- "{% load i18n %}{% blocktranslate %}There are %(num_comments)s comments{% endblocktranslate %}"
+ "{% load i18n %}{% blocktranslate %}There are %(num_comments)s comments"
+ "{% endblocktranslate %}"
)
t_plur = self.get_template(
"{% load i18n %}{% blocktranslate count num as number %}"
diff --git a/tests/template_tests/syntax_tests/i18n/test_get_available_languages.py b/tests/template_tests/syntax_tests/i18n/test_get_available_languages.py
index dce5a4de66..ce2e60c0d9 100644
--- a/tests/template_tests/syntax_tests/i18n/test_get_available_languages.py
+++ b/tests/template_tests/syntax_tests/i18n/test_get_available_languages.py
@@ -20,6 +20,9 @@ class GetAvailableLanguagesTagTests(SimpleTestCase):
@setup({"syntax_i18n": "{% load i18n %}{% get_available_languages a langs %}"})
def test_no_as_var(self):
- msg = "'get_available_languages' requires 'as variable' (got ['get_available_languages', 'a', 'langs'])"
+ msg = (
+ "'get_available_languages' requires 'as variable' (got "
+ "['get_available_languages', 'a', 'langs'])"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("syntax_i18n")
diff --git a/tests/template_tests/syntax_tests/i18n/test_get_current_language.py b/tests/template_tests/syntax_tests/i18n/test_get_current_language.py
index 8ed7f742c2..7de1b53bd9 100644
--- a/tests/template_tests/syntax_tests/i18n/test_get_current_language.py
+++ b/tests/template_tests/syntax_tests/i18n/test_get_current_language.py
@@ -9,6 +9,9 @@ class I18nGetCurrentLanguageTagTests(SimpleTestCase):
@setup({"template": "{% load i18n %} {% get_current_language %}"})
def test_no_as_var(self):
- msg = "'get_current_language' requires 'as variable' (got ['get_current_language'])"
+ msg = (
+ "'get_current_language' requires 'as variable' (got "
+ "['get_current_language'])"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("template")
diff --git a/tests/template_tests/syntax_tests/i18n/test_get_current_language_bidi.py b/tests/template_tests/syntax_tests/i18n/test_get_current_language_bidi.py
index 3f307471ae..9b57047209 100644
--- a/tests/template_tests/syntax_tests/i18n/test_get_current_language_bidi.py
+++ b/tests/template_tests/syntax_tests/i18n/test_get_current_language_bidi.py
@@ -9,6 +9,9 @@ class I18nGetCurrentLanguageBidiTagTests(SimpleTestCase):
@setup({"template": "{% load i18n %} {% get_current_language_bidi %}"})
def test_no_as_var(self):
- msg = "'get_current_language_bidi' requires 'as variable' (got ['get_current_language_bidi'])"
+ msg = (
+ "'get_current_language_bidi' requires 'as variable' (got "
+ "['get_current_language_bidi'])"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("template")
diff --git a/tests/template_tests/syntax_tests/i18n/test_get_language_info_list.py b/tests/template_tests/syntax_tests/i18n/test_get_language_info_list.py
index 93038daa2f..962c888782 100644
--- a/tests/template_tests/syntax_tests/i18n/test_get_language_info_list.py
+++ b/tests/template_tests/syntax_tests/i18n/test_get_language_info_list.py
@@ -65,6 +65,9 @@ class GetLanguageInfoListTests(SimpleTestCase):
@setup({"i18n_syntax": "{% load i18n %} {% get_language_info_list error %}"})
def test_no_for_as(self):
- msg = "'get_language_info_list' requires 'for sequence as variable' (got ['error'])"
+ msg = (
+ "'get_language_info_list' requires 'for sequence as variable' (got "
+ "['error'])"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("i18n_syntax")
diff --git a/tests/template_tests/syntax_tests/i18n/test_translate.py b/tests/template_tests/syntax_tests/i18n/test_translate.py
index 932b47a373..d8a224df9d 100644
--- a/tests/template_tests/syntax_tests/i18n/test_translate.py
+++ b/tests/template_tests/syntax_tests/i18n/test_translate.py
@@ -84,7 +84,9 @@ class I18nTransTagTests(SimpleTestCase):
@setup(
{
- "i18n23": '{% load i18n %}{% translate "Page not found"|capfirst|slice:"6:" %}'
+ "i18n23": (
+ '{% load i18n %}{% translate "Page not found"|capfirst|slice:"6:" %}'
+ )
}
)
def test_i18n23(self):
@@ -110,7 +112,10 @@ class I18nTransTagTests(SimpleTestCase):
# trans tag with as var
@setup(
{
- "i18n35": '{% load i18n %}{% translate "Page not found" as page_not_found %}{{ page_not_found }}'
+ "i18n35": (
+ '{% load i18n %}{% translate "Page not found" as page_not_found %}'
+ "{{ page_not_found }}"
+ )
}
)
def test_i18n35(self):
@@ -120,8 +125,10 @@ class I18nTransTagTests(SimpleTestCase):
@setup(
{
- "i18n36": "{% load i18n %}"
- '{% translate "Page not found" noop as page_not_found %}{{ page_not_found }}'
+ "i18n36": (
+ '{% load i18n %}{% translate "Page not found" noop as page_not_found %}'
+ "{{ page_not_found }}"
+ )
}
)
def test_i18n36(self):
@@ -157,16 +164,18 @@ class I18nTransTagTests(SimpleTestCase):
@setup({"template": '{% load i18n %}{% translate "Yes" context as var %}'})
def test_syntax_error_context_as(self, tag_name):
- msg = "Invalid argument 'as' provided to the '{}' tag for the context option".format(
- tag_name
+ msg = (
+ f"Invalid argument 'as' provided to the '{tag_name}' tag for the context "
+ f"option"
)
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("template")
@setup({"template": '{% load i18n %}{% translate "Yes" context noop %}'})
def test_syntax_error_context_noop(self, tag_name):
- msg = "Invalid argument 'noop' provided to the '{}' tag for the context option".format(
- tag_name
+ msg = (
+ f"Invalid argument 'noop' provided to the '{tag_name}' tag for the context "
+ f"option"
)
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string("template")
@@ -240,12 +249,14 @@ class TranslationTransTagTests(SimpleTestCase):
# Using 'as'
t = self.get_template(
- '{% load i18n %}{% translate "May" context "month name" as var %}Value: {{ var }}'
+ '{% load i18n %}{% translate "May" context "month name" as var %}'
+ "Value: {{ var }}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "Value: Mai")
t = self.get_template(
- '{% load i18n %}{% translate "May" as var context "verb" %}Value: {{ var }}'
+ '{% load i18n %}{% translate "May" as var context "verb" %}Value: '
+ "{{ var }}"
)
rendered = t.render(Context())
self.assertEqual(rendered, "Value: Kann")
diff --git a/tests/template_tests/syntax_tests/i18n/test_underscore_syntax.py b/tests/template_tests/syntax_tests/i18n/test_underscore_syntax.py
index dfb035999c..ac6a22ed46 100644
--- a/tests/template_tests/syntax_tests/i18n/test_underscore_syntax.py
+++ b/tests/template_tests/syntax_tests/i18n/test_underscore_syntax.py
@@ -90,7 +90,10 @@ class I18nStringLiteralTests(SimpleTestCase):
@setup(
{
- "i18n14": '{% cycle "foo" _("Password") _(\'Password\') as c %} {% cycle c %} {% cycle c %}'
+ "i18n14": (
+ '{% cycle "foo" _("Password") _(\'Password\') as c %} {% cycle c %} '
+ "{% cycle c %}"
+ )
}
)
def test_i18n14(self):
diff --git a/tests/template_tests/syntax_tests/test_autoescape.py b/tests/template_tests/syntax_tests/test_autoescape.py
index d3c5cb02da..a45b850fcf 100644
--- a/tests/template_tests/syntax_tests/test_autoescape.py
+++ b/tests/template_tests/syntax_tests/test_autoescape.py
@@ -28,7 +28,10 @@ class AutoescapeTagTests(SimpleTestCase):
# Autoescape disabling and enabling nest in a predictable way.
@setup(
{
- "autoescape-tag04": "{% autoescape off %}{{ first }} {% autoescape on %}{{ first }}{% endautoescape %}{% endautoescape %}"
+ "autoescape-tag04": (
+ "{% autoescape off %}{{ first }} {% autoescape on %}{{ first }}"
+ "{% endautoescape %}{% endautoescape %}"
+ )
}
)
def test_autoescape_tag04(self):
@@ -60,7 +63,10 @@ class AutoescapeTagTests(SimpleTestCase):
@setup(
{
- "autoescape-tag08": r'{% autoescape on %}{{ var|default_if_none:" endquote\" hah" }}{% endautoescape %}'
+ "autoescape-tag08": (
+ r'{% autoescape on %}{{ var|default_if_none:" endquote\" hah" }}'
+ r"{% endautoescape %}"
+ )
}
)
def test_autoescape_tag08(self):
@@ -86,7 +92,9 @@ class AutoescapeTagTests(SimpleTestCase):
@setup(
{
- "autoescape-filtertag01": "{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}"
+ "autoescape-filtertag01": (
+ "{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}"
+ )
}
)
def test_autoescape_filtertag01(self):
@@ -143,7 +151,9 @@ class AutoescapeTagTests(SimpleTestCase):
@setup(
{
- "autoescape-incorrect-arg": "{% autoescape true %}{{ var.key }}{% endautoescape %}"
+ "autoescape-incorrect-arg": (
+ "{% autoescape true %}{{ var.key }}{% endautoescape %}"
+ )
}
)
def test_invalid_arg(self):
diff --git a/tests/template_tests/syntax_tests/test_cache.py b/tests/template_tests/syntax_tests/test_cache.py
index a722420637..9dcf9a6b5a 100644
--- a/tests/template_tests/syntax_tests/test_cache.py
+++ b/tests/template_tests/syntax_tests/test_cache.py
@@ -105,7 +105,10 @@ class CacheTagTests(SimpleTestCase):
@setup(
{
- "cache17": "{% load cache %}{% cache 10 long_cache_key poem %}Some Content{% endcache %}"
+ "cache17": (
+ "{% load cache %}{% cache 10 long_cache_key poem %}Some Content"
+ "{% endcache %}"
+ )
}
)
def test_cache17(self):
@@ -119,8 +122,8 @@ class CacheTagTests(SimpleTestCase):
"Oh freddled gruntbuggly/Thy micturations are to me/"
"As plurdled gabbleblotchits/On a lurgid bee/"
"That mordiously hath bitled out/Its earted jurtles/"
- "Into a rancid festering/Or else I shall rend thee in the gobberwarts"
- "with my blurglecruncheon/See if I don't."
+ "Into a rancid festering/Or else I shall rend thee in the "
+ "gobberwarts with my blurglecruncheon/See if I don't."
),
},
)
@@ -128,7 +131,10 @@ class CacheTagTests(SimpleTestCase):
@setup(
{
- "cache18": '{% load cache custom %}{% cache 2|noop:"x y" cache18 %}cache18{% endcache %}'
+ "cache18": (
+ '{% load cache custom %}{% cache 2|noop:"x y" cache18 %}cache18'
+ "{% endcache %}"
+ )
}
)
def test_cache18(self):
@@ -141,7 +147,9 @@ class CacheTagTests(SimpleTestCase):
@setup(
{
"first": "{% load cache %}{% cache None fragment19 %}content{% endcache %}",
- "second": "{% load cache %}{% cache None fragment19 %}not rendered{% endcache %}",
+ "second": (
+ "{% load cache %}{% cache None fragment19 %}not rendered{% endcache %}"
+ ),
}
)
def test_none_timeout(self):
diff --git a/tests/template_tests/syntax_tests/test_cycle.py b/tests/template_tests/syntax_tests/test_cycle.py
index d4233fac3e..cff0363e38 100644
--- a/tests/template_tests/syntax_tests/test_cycle.py
+++ b/tests/template_tests/syntax_tests/test_cycle.py
@@ -35,7 +35,10 @@ class CycleTagTests(SimpleTestCase):
@setup(
{
- "cycle12": "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}"
+ "cycle12": (
+ "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}{% cycle abc %}"
+ "{% cycle abc %}"
+ )
}
)
def test_cycle12(self):
@@ -106,7 +109,10 @@ class CycleTagTests(SimpleTestCase):
@setup(
{
- "cycle22": "{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ x }}{% endfor %}"
+ "cycle22": (
+ "{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ x }}"
+ "{% endfor %}"
+ )
}
)
def test_cycle22(self):
@@ -125,8 +131,11 @@ class CycleTagTests(SimpleTestCase):
@setup(
{
- "cycle24": "{% for x in values %}"
- "{% cycle 'a' 'b' 'c' as abc silent %}{% include 'included-cycle' %}{% endfor %}",
+ "cycle24": (
+ "{% for x in values %}"
+ "{% cycle 'a' 'b' 'c' as abc silent %}{% include 'included-cycle' %}"
+ "{% endfor %}"
+ ),
"included-cycle": "{{ abc }}",
}
)
@@ -146,7 +155,10 @@ class CycleTagTests(SimpleTestCase):
@setup(
{
- "cycle27": "{% autoescape off %}{% cycle a b as ab %}{% cycle ab %}{% endautoescape %}"
+ "cycle27": (
+ "{% autoescape off %}{% cycle a b as ab %}{% cycle ab %}"
+ "{% endautoescape %}"
+ )
}
)
def test_cycle27(self):
diff --git a/tests/template_tests/syntax_tests/test_exceptions.py b/tests/template_tests/syntax_tests/test_exceptions.py
index 7000b45afd..b6d86ac42b 100644
--- a/tests/template_tests/syntax_tests/test_exceptions.py
+++ b/tests/template_tests/syntax_tests/test_exceptions.py
@@ -42,13 +42,17 @@ class ExceptionsTests(SimpleTestCase):
@setup(
{
- "exception04": "{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}"
+ "exception04": (
+ "{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678"
+ "{% endblock %}"
+ )
},
inheritance_templates,
)
def test_exception04(self):
"""
- Raise exception for custom tags used in child with {% load %} tag in parent, not in child
+ Raise exception for custom tags used in child with {% load %} tag in
+ parent, not in child
"""
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template("exception04")
diff --git a/tests/template_tests/syntax_tests/test_extends.py b/tests/template_tests/syntax_tests/test_extends.py
index ce073fb909..9f5dae0db4 100644
--- a/tests/template_tests/syntax_tests/test_extends.py
+++ b/tests/template_tests/syntax_tests/test_extends.py
@@ -6,7 +6,9 @@ from django.test import SimpleTestCase
from ..utils import setup
inheritance_templates = {
- "inheritance01": "1{% block first %}&{% endblock %}3{% block second %}_{% endblock %}",
+ "inheritance01": (
+ "1{% block first %}&{% endblock %}3{% block second %}_{% endblock %}"
+ ),
"inheritance02": "{% extends 'inheritance01' %}"
"{% block first %}2{% endblock %}{% block second %}4{% endblock %}",
"inheritance03": "{% extends 'inheritance02' %}",
@@ -22,7 +24,9 @@ inheritance_templates = {
"inheritance12": "{% extends 'inheritance07' %}{% block first %}2{% endblock %}",
"inheritance13": "{% extends 'inheritance02' %}"
"{% block first %}a{% endblock %}{% block second %}b{% endblock %}",
- "inheritance14": "{% extends 'inheritance01' %}{% block newblock %}NO DISPLAY{% endblock %}",
+ "inheritance14": (
+ "{% extends 'inheritance01' %}{% block newblock %}NO DISPLAY{% endblock %}"
+ ),
"inheritance15": "{% extends 'inheritance01' %}"
"{% block first %}2{% block inner %}inner{% endblock %}{% endblock %}",
"inheritance16": "{% extends 'inheritance15' %}{% block inner %}out{% endblock %}",
@@ -30,10 +34,18 @@ inheritance_templates = {
"inheritance18": "{% load testtags %}{% echo this that theother %}5678",
"inheritance19": "{% extends 'inheritance01' %}"
"{% block first %}{% load testtags %}{% echo 400 %}5678{% endblock %}",
- "inheritance20": "{% extends 'inheritance01' %}{% block first %}{{ block.super }}a{% endblock %}",
- "inheritance21": "{% extends 'inheritance02' %}{% block first %}{{ block.super }}a{% endblock %}",
- "inheritance22": "{% extends 'inheritance04' %}{% block first %}{{ block.super }}a{% endblock %}",
- "inheritance23": "{% extends 'inheritance20' %}{% block first %}{{ block.super }}b{% endblock %}",
+ "inheritance20": (
+ "{% extends 'inheritance01' %}{% block first %}{{ block.super }}a{% endblock %}"
+ ),
+ "inheritance21": (
+ "{% extends 'inheritance02' %}{% block first %}{{ block.super }}a{% endblock %}"
+ ),
+ "inheritance22": (
+ "{% extends 'inheritance04' %}{% block first %}{{ block.super }}a{% endblock %}"
+ ),
+ "inheritance23": (
+ "{% extends 'inheritance20' %}{% block first %}{{ block.super }}b{% endblock %}"
+ ),
"inheritance24": "{% extends context_template %}"
"{% block first %}2{% endblock %}{% block second %}4{% endblock %}",
"inheritance25": "{% extends context_template.1 %}"
@@ -45,19 +57,32 @@ inheritance_templates = {
"inheritance30": "1{% if optional %}{% block opt %}2{% endblock %}{% endif %}3",
"inheritance31": "{% extends 'inheritance30' %}{% block opt %}two{% endblock %}",
"inheritance32": "{% extends 'inheritance30' %}{% block opt %}two{% endblock %}",
- "inheritance33": "1{% if optional == 1 %}{% block opt %}2{% endblock %}{% endif %}3",
+ "inheritance33": (
+ "1{% if optional == 1 %}{% block opt %}2{% endblock %}{% endif %}3"
+ ),
"inheritance34": "{% extends 'inheritance33' %}{% block opt %}two{% endblock %}",
"inheritance35": "{% extends 'inheritance33' %}{% block opt %}two{% endblock %}",
- "inheritance36": "{% for n in numbers %}_{% block opt %}{{ n }}{% endblock %}{% endfor %}_",
+ "inheritance36": (
+ "{% for n in numbers %}_{% block opt %}{{ n }}{% endblock %}{% endfor %}_"
+ ),
"inheritance37": "{% extends 'inheritance36' %}{% block opt %}X{% endblock %}",
"inheritance38": "{% extends 'inheritance36' %}{% block opt %}X{% endblock %}",
- "inheritance39": "{% extends 'inheritance30' %}{% block opt %}new{{ block.super }}{% endblock %}",
- "inheritance40": "{% extends 'inheritance33' %}{% block opt %}new{{ block.super }}{% endblock %}",
- "inheritance41": "{% extends 'inheritance36' %}{% block opt %}new{{ block.super }}{% endblock %}",
+ "inheritance39": (
+ "{% extends 'inheritance30' %}{% block opt %}new{{ block.super }}{% endblock %}"
+ ),
+ "inheritance40": (
+ "{% extends 'inheritance33' %}{% block opt %}new{{ block.super }}{% endblock %}"
+ ),
+ "inheritance41": (
+ "{% extends 'inheritance36' %}{% block opt %}new{{ block.super }}{% endblock %}"
+ ),
"inheritance42": "{% extends 'inheritance02'|cut:' ' %}",
"inheritance_empty": "{% extends %}",
"extends_duplicate": "{% extends 'base.html' %}{% extends 'base.html' %}",
- "duplicate_block": "{% extends 'base.html' %}{% block content %}2{% endblock %}{% block content %}4{% endblock %}",
+ "duplicate_block": (
+ "{% extends 'base.html' %}{% block content %}2{% endblock %}{% block content %}"
+ "4{% endblock %}"
+ ),
}
diff --git a/tests/template_tests/syntax_tests/test_for.py b/tests/template_tests/syntax_tests/test_for.py
index ad1d158f9b..a47a99ac65 100644
--- a/tests/template_tests/syntax_tests/test_for.py
+++ b/tests/template_tests/syntax_tests/test_for.py
@@ -34,7 +34,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-vars03": "{% for val in values %}{{ forloop.revcounter }}{% endfor %}"
+ "for-tag-vars03": (
+ "{% for val in values %}{{ forloop.revcounter }}{% endfor %}"
+ )
}
)
def test_for_tag_vars03(self):
@@ -43,7 +45,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-vars04": "{% for val in values %}{{ forloop.revcounter0 }}{% endfor %}"
+ "for-tag-vars04": (
+ "{% for val in values %}{{ forloop.revcounter0 }}{% endfor %}"
+ )
}
)
def test_for_tag_vars04(self):
@@ -72,7 +76,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack01": "{% for key,value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack01": (
+ "{% for key,value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack01(self):
@@ -83,7 +89,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack03": "{% for key, value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack03": (
+ "{% for key, value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack03(self):
@@ -94,7 +102,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack04": "{% for key , value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack04": (
+ "{% for key , value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack04(self):
@@ -105,7 +115,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack05": "{% for key ,value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack05": (
+ "{% for key ,value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack05(self):
@@ -116,7 +128,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack06": "{% for key value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack06": (
+ "{% for key value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack06(self):
@@ -128,7 +142,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack07": "{% for key,,value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack07": (
+ "{% for key,,value in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack07(self):
@@ -140,7 +156,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack08": "{% for key,value, in items %}{{ key }}:{{ value }}/{% endfor %}"
+ "for-tag-unpack08": (
+ "{% for key,value, in items %}{{ key }}:{{ value }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack08(self):
@@ -170,7 +188,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack09": "{% for val in items %}{{ val.0 }}:{{ val.1 }}/{% endfor %}"
+ "for-tag-unpack09": (
+ "{% for val in items %}{{ val.0 }}:{{ val.1 }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack09(self):
@@ -184,7 +204,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack13": "{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}"
+ "for-tag-unpack13": (
+ "{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack13(self):
@@ -198,7 +220,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-empty01": "{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}"
+ "for-tag-empty01": (
+ "{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}"
+ )
}
)
def test_for_tag_empty01(self):
@@ -207,7 +231,10 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-empty02": "{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}"
+ "for-tag-empty02": (
+ "{% for val in values %}{{ val }}{% empty %}values array empty"
+ "{% endfor %}"
+ )
}
)
def test_for_tag_empty02(self):
@@ -226,7 +253,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-filter-ws": "{% load custom %}{% for x in s|noop:'x y' %}{{ x }}{% endfor %}"
+ "for-tag-filter-ws": (
+ "{% load custom %}{% for x in s|noop:'x y' %}{{ x }}{% endfor %}"
+ )
}
)
def test_for_tag_filter_ws(self):
@@ -257,7 +286,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack11": "{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}"
+ "for-tag-unpack11": (
+ "{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack11(self):
@@ -271,7 +302,9 @@ class ForTagTests(SimpleTestCase):
@setup(
{
- "for-tag-unpack12": "{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}"
+ "for-tag-unpack12": (
+ "{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}"
+ )
}
)
def test_for_tag_unpack12(self):
diff --git a/tests/template_tests/syntax_tests/test_if.py b/tests/template_tests/syntax_tests/test_if.py
index fda44b0672..36077f0687 100644
--- a/tests/template_tests/syntax_tests/test_if.py
+++ b/tests/template_tests/syntax_tests/test_if.py
@@ -53,7 +53,10 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "if-tag10": "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}"
+ "if-tag10": (
+ "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing"
+ "{% endif %}"
+ )
}
)
def test_if_tag10(self):
@@ -62,7 +65,10 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "if-tag11": "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}"
+ "if-tag11": (
+ "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing"
+ "{% endif %}"
+ )
}
)
def test_if_tag11(self):
@@ -71,7 +77,10 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "if-tag12": "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}"
+ "if-tag12": (
+ "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing"
+ "{% endif %}"
+ )
}
)
def test_if_tag12(self):
@@ -80,7 +89,10 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "if-tag13": "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}"
+ "if-tag13": (
+ "{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing"
+ "{% endif %}"
+ )
}
)
def test_if_tag13(self):
@@ -588,7 +600,9 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "else-if-tag-error01": "{% if foo is bar %} yes {% else if foo is not bar %} no {% endif %}"
+ "else-if-tag-error01": (
+ "{% if foo is bar %} yes {% else if foo is not bar %} no {% endif %}"
+ )
}
)
def test_else_if_tag_error01(self):
@@ -598,7 +612,9 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "if-tag-shortcircuit01": "{% if x.is_true or x.is_bad %}yes{% else %}no{% endif %}"
+ "if-tag-shortcircuit01": (
+ "{% if x.is_true or x.is_bad %}yes{% else %}no{% endif %}"
+ )
}
)
def test_if_tag_shortcircuit01(self):
@@ -610,7 +626,9 @@ class IfTagTests(SimpleTestCase):
@setup(
{
- "if-tag-shortcircuit02": "{% if x.is_false and x.is_bad %}yes{% else %}no{% endif %}"
+ "if-tag-shortcircuit02": (
+ "{% if x.is_false and x.is_bad %}yes{% else %}no{% endif %}"
+ )
}
)
def test_if_tag_shortcircuit02(self):
diff --git a/tests/template_tests/syntax_tests/test_if_changed.py b/tests/template_tests/syntax_tests/test_if_changed.py
index 3835e52d78..fb0a693460 100644
--- a/tests/template_tests/syntax_tests/test_if_changed.py
+++ b/tests/template_tests/syntax_tests/test_if_changed.py
@@ -9,7 +9,9 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged01": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
+ "ifchanged01": (
+ "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
+ )
}
)
def test_ifchanged01(self):
@@ -18,7 +20,9 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged02": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
+ "ifchanged02": (
+ "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
+ )
}
)
def test_ifchanged02(self):
@@ -27,7 +31,9 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged03": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
+ "ifchanged03": (
+ "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
+ )
}
)
def test_ifchanged03(self):
@@ -108,8 +114,10 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged-param01": "{% for n in num %}{% ifchanged n %}..{% endifchanged %}"
- "{{ n }}{% endfor %}"
+ "ifchanged-param01": (
+ "{% for n in num %}{% ifchanged n %}..{% endifchanged %}"
+ "{{ n }}{% endfor %}"
+ )
}
)
def test_ifchanged_param01(self):
@@ -121,8 +129,11 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged-param02": "{% for n in num %}{% for x in numx %}{% ifchanged n %}..{% endifchanged %}"
- "{{ x }}{% endfor %}{% endfor %}"
+ "ifchanged-param02": (
+ "{% for n in num %}{% for x in numx %}"
+ "{% ifchanged n %}..{% endifchanged %}{{ x }}"
+ "{% endfor %}{% endfor %}"
+ )
}
)
def test_ifchanged_param02(self):
@@ -149,9 +160,11 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged-param04": "{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}"
- "{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}"
- "{% endfor %}{% endfor %}"
+ "ifchanged-param04": (
+ "{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}"
+ "{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}"
+ "{% endfor %}{% endfor %}"
+ )
}
)
def test_ifchanged_param04(self):
@@ -167,9 +180,11 @@ class IfChangedTagTests(SimpleTestCase):
@setup(
{
- "ifchanged-param05": "{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}"
- "{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}"
- "{% endfor %}{% endfor %}"
+ "ifchanged-param05": (
+ "{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}"
+ "{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}"
+ "{% endfor %}{% endfor %}"
+ )
}
)
def test_ifchanged_param05(self):
@@ -275,7 +290,8 @@ class IfChangedTests(SimpleTestCase):
yield 1
yield 2
# Simulate that another thread is now rendering.
- # When the IfChangeNode stores state at 'self' it stays at '3' and skip the last yielded value below.
+ # When the IfChangeNode stores state at 'self' it stays at '3' and
+ # skip the last yielded value below.
iter2 = iter([1, 2, 3])
output2 = template.render(
Context({"foo": range(3), "get_value": lambda: next(iter2)})
@@ -319,7 +335,9 @@ class IfChangedTests(SimpleTestCase):
(
"django.template.loaders.locmem.Loader",
{
- "template": '{% for x in vars %}{% include "include" %}{% endfor %}',
+ "template": (
+ '{% for x in vars %}{% include "include" %}{% endfor %}'
+ ),
"include": "{% ifchanged %}{{ x }}{% endifchanged %}",
},
),
@@ -335,7 +353,10 @@ class IfChangedTests(SimpleTestCase):
(
"django.template.loaders.locmem.Loader",
{
- "template": '{% for x in vars %}{% include "include" %}{% include "include" %}{% endfor %}',
+ "template": (
+ '{% for x in vars %}{% include "include" %}'
+ '{% include "include" %}{% endfor %}'
+ ),
"include": "{% ifchanged %}{{ x }}{% endifchanged %}",
},
),
diff --git a/tests/template_tests/syntax_tests/test_include.py b/tests/template_tests/syntax_tests/test_include.py
index add2ca139f..3ee99b3798 100644
--- a/tests/template_tests/syntax_tests/test_include.py
+++ b/tests/template_tests/syntax_tests/test_include.py
@@ -73,9 +73,12 @@ class IncludeTagTests(SimpleTestCase):
@setup(
{
- "include09": "{{ first }}--"
- '{% include "basic-syntax03" with first=second|lower|upper second=first|upper %}'
- "--{{ second }}"
+ "include09": (
+ "{{ first }}--"
+ '{% include "basic-syntax03" with '
+ "first=second|lower|upper second=first|upper %}"
+ "--{{ second }}"
+ )
},
basic_templates,
)
@@ -117,7 +120,9 @@ class IncludeTagTests(SimpleTestCase):
@setup(
{
- "include13": '{% autoescape off %}{% include "basic-syntax03" %}{% endautoescape %}'
+ "include13": (
+ '{% autoescape off %}{% include "basic-syntax03" %}{% endautoescape %}'
+ )
},
basic_templates,
)
@@ -350,7 +355,9 @@ class IncludeTests(SimpleTestCase):
(
"django.template.loaders.locmem.Loader",
{
- "template": '{% for x in vars %}{% include "include" %}{% endfor %}',
+ "template": (
+ '{% for x in vars %}{% include "include" %}{% endfor %}'
+ ),
"include": '{% include "next" %}',
"next": "{% load custom %}{% counter %}",
},
diff --git a/tests/template_tests/syntax_tests/test_invalid_string.py b/tests/template_tests/syntax_tests/test_invalid_string.py
index e65ac938ec..d8601febf1 100644
--- a/tests/template_tests/syntax_tests/test_invalid_string.py
+++ b/tests/template_tests/syntax_tests/test_invalid_string.py
@@ -55,7 +55,9 @@ class InvalidStringTests(SimpleTestCase):
@setup(
{
- "invalidstr07": "{% load i18n %}{% blocktranslate %}{{ var }}{% endblocktranslate %}"
+ "invalidstr07": (
+ "{% load i18n %}{% blocktranslate %}{{ var }}{% endblocktranslate %}"
+ )
}
)
def test_invalidstr07(self):
diff --git a/tests/template_tests/syntax_tests/test_load.py b/tests/template_tests/syntax_tests/test_load.py
index ae5f1d4b48..a13871b247 100644
--- a/tests/template_tests/syntax_tests/test_load.py
+++ b/tests/template_tests/syntax_tests/test_load.py
@@ -12,7 +12,9 @@ class LoadTagTests(SimpleTestCase):
@setup(
{
- "load01": '{% load testtags subpackage.echo %}{% echo test %} {% echo2 "test" %}'
+ "load01": (
+ '{% load testtags subpackage.echo %}{% echo test %} {% echo2 "test" %}'
+ )
}
)
def test_load01(self):
@@ -64,24 +66,36 @@ class LoadTagTests(SimpleTestCase):
@setup({"load08": "{% load echo other_echo bad_tag from %}"})
def test_load08(self):
- msg = "'echo' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ msg = (
+ "'echo' is not a registered tag library. Must be one of:\n"
+ "subpackage.echo\ntesttags"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template("load08")
@setup({"load09": "{% load from testtags %}"})
def test_load09(self):
- msg = "'from' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ msg = (
+ "'from' is not a registered tag library. Must be one of:\n"
+ "subpackage.echo\ntesttags"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template("load09")
@setup({"load10": "{% load echo from bad_library %}"})
def test_load10(self):
- msg = "'bad_library' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ msg = (
+ "'bad_library' is not a registered tag library. Must be one of:\n"
+ "subpackage.echo\ntesttags"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template("load10")
@setup({"load12": "{% load subpackage.missing %}"})
def test_load12(self):
- msg = "'subpackage.missing' is not a registered tag library. Must be one of:\nsubpackage.echo\ntesttags"
+ msg = (
+ "'subpackage.missing' is not a registered tag library. Must be one of:\n"
+ "subpackage.echo\ntesttags"
+ )
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template("load12")
diff --git a/tests/template_tests/syntax_tests/test_named_endblock.py b/tests/template_tests/syntax_tests/test_named_endblock.py
index 2230edf52b..7469a28778 100644
--- a/tests/template_tests/syntax_tests/test_named_endblock.py
+++ b/tests/template_tests/syntax_tests/test_named_endblock.py
@@ -48,7 +48,9 @@ class NamedEndblockTests(SimpleTestCase):
@setup(
{
- "namedendblocks05": "1{% block first %}_{% block second %}2{% endblock first %}"
+ "namedendblocks05": (
+ "1{% block first %}_{% block second %}2{% endblock first %}"
+ )
}
)
def test_namedendblocks05(self):
diff --git a/tests/template_tests/syntax_tests/test_resetcycle.py b/tests/template_tests/syntax_tests/test_resetcycle.py
index 6d7365a6ec..fb67b3368e 100644
--- a/tests/template_tests/syntax_tests/test_resetcycle.py
+++ b/tests/template_tests/syntax_tests/test_resetcycle.py
@@ -33,7 +33,9 @@ class ResetCycleTagTests(SimpleTestCase):
@setup(
{
- "resetcycle05": "{% for i in test %}{% cycle 'a' 'b' %}{% resetcycle %}{% endfor %}"
+ "resetcycle05": (
+ "{% for i in test %}{% cycle 'a' 'b' %}{% resetcycle %}{% endfor %}"
+ )
}
)
def test_resetcycle05(self):
diff --git a/tests/template_tests/syntax_tests/test_spaceless.py b/tests/template_tests/syntax_tests/test_spaceless.py
index 8bb20dba6c..e86c60f06b 100644
--- a/tests/template_tests/syntax_tests/test_spaceless.py
+++ b/tests/template_tests/syntax_tests/test_spaceless.py
@@ -6,7 +6,9 @@ from ..utils import setup
class SpacelessTagTests(SimpleTestCase):
@setup(
{
- "spaceless01": "{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}"
+ "spaceless01": (
+ "{% spaceless %} <b> <i> text </i> </b> {% endspaceless %}"
+ )
}
)
def test_spaceless01(self):
@@ -15,7 +17,9 @@ class SpacelessTagTests(SimpleTestCase):
@setup(
{
- "spaceless02": "{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}"
+ "spaceless02": (
+ "{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}"
+ )
}
)
def test_spaceless02(self):
@@ -29,7 +33,9 @@ class SpacelessTagTests(SimpleTestCase):
@setup(
{
- "spaceless04": "{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}"
+ "spaceless04": (
+ "{% spaceless %}<b> <i>{{ text }}</i> </b>{% endspaceless %}"
+ )
}
)
def test_spaceless04(self):
@@ -49,7 +55,9 @@ class SpacelessTagTests(SimpleTestCase):
@setup(
{
- "spaceless06": "{% spaceless %}<b> <i>{{ text|safe }}</i> </b>{% endspaceless %}"
+ "spaceless06": (
+ "{% spaceless %}<b> <i>{{ text|safe }}</i> </b>{% endspaceless %}"
+ )
}
)
def test_spaceless06(self):
diff --git a/tests/template_tests/syntax_tests/test_static.py b/tests/template_tests/syntax_tests/test_static.py
index cd63350cb5..63265f57f3 100644
--- a/tests/template_tests/syntax_tests/test_static.py
+++ b/tests/template_tests/syntax_tests/test_static.py
@@ -44,7 +44,10 @@ class StaticTagTests(SimpleTestCase):
@setup(
{
- "t": "{% load static %}{% get_media_prefix ad media_prefix %}{{ media_prefix }}"
+ "t": (
+ "{% load static %}{% get_media_prefix ad media_prefix %}"
+ "{{ media_prefix }}"
+ )
}
)
def test_static_prefixtag_without_as(self):
@@ -66,7 +69,9 @@ class StaticTagTests(SimpleTestCase):
@setup(
{
- "static-statictag03": '{% load static %}{% static "admin/base.css" as foo %}{{ foo }}'
+ "static-statictag03": (
+ '{% load static %}{% static "admin/base.css" as foo %}{{ foo }}'
+ )
}
)
def test_static_statictag03(self):
@@ -84,7 +89,9 @@ class StaticTagTests(SimpleTestCase):
@setup(
{
- "static-statictag05": '{% load static %}{% static "special?chars&quoted.html" %}'
+ "static-statictag05": (
+ '{% load static %}{% static "special?chars&quoted.html" %}'
+ )
}
)
def test_static_quotes_urls(self):
diff --git a/tests/template_tests/syntax_tests/test_verbatim.py b/tests/template_tests/syntax_tests/test_verbatim.py
index afb08e013a..16e0239177 100644
--- a/tests/template_tests/syntax_tests/test_verbatim.py
+++ b/tests/template_tests/syntax_tests/test_verbatim.py
@@ -24,7 +24,9 @@ class VerbatimTagTests(SimpleTestCase):
@setup(
{
- "verbatim-tag04": "{% verbatim %}{% verbatim %}{% endverbatim %}{% endverbatim %}"
+ "verbatim-tag04": (
+ "{% verbatim %}{% verbatim %}{% endverbatim %}{% endverbatim %}"
+ )
}
)
def test_verbatim_tag04(self):
@@ -33,7 +35,9 @@ class VerbatimTagTests(SimpleTestCase):
@setup(
{
- "verbatim-tag05": "{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}"
+ "verbatim-tag05": (
+ "{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}"
+ )
}
)
def test_verbatim_tag05(self):