diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-04 08:08:27 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
| commit | 7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch) | |
| tree | fa50869f5614295f462d9bf77fec59365c621609 /tests/template_tests | |
| parent | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff) | |
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/template_tests')
61 files changed, 800 insertions, 301 deletions
diff --git a/tests/template_tests/filter_tests/test_addslashes.py b/tests/template_tests/filter_tests/test_addslashes.py index 2626918f3d..fe42f529fd 100644 --- a/tests/template_tests/filter_tests/test_addslashes.py +++ b/tests/template_tests/filter_tests/test_addslashes.py @@ -8,7 +8,10 @@ from ..utils import setup class AddslashesTests(SimpleTestCase): @setup( { - "addslashes01": "{% autoescape off %}{{ a|addslashes }} {{ b|addslashes }}{% endautoescape %}" + "addslashes01": ( + "{% autoescape off %}{{ a|addslashes }} {{ b|addslashes }}" + "{% endautoescape %}" + ) } ) def test_addslashes01(self): diff --git a/tests/template_tests/filter_tests/test_autoescape.py b/tests/template_tests/filter_tests/test_autoescape.py index de58956f2c..c7cc9deb4a 100644 --- a/tests/template_tests/filter_tests/test_autoescape.py +++ b/tests/template_tests/filter_tests/test_autoescape.py @@ -17,7 +17,9 @@ class AutoescapeStringfilterTests(SimpleTestCase): @setup( { - "autoescape-stringfilter02": "{% autoescape off %}{{ unsafe|capfirst }}{% endautoescape %}" + "autoescape-stringfilter02": ( + "{% autoescape off %}{{ unsafe|capfirst }}{% endautoescape %}" + ) } ) def test_autoescape_stringfilter02(self): @@ -35,7 +37,9 @@ class AutoescapeStringfilterTests(SimpleTestCase): @setup( { - "autoescape-stringfilter04": "{% autoescape off %}{{ safe|capfirst }}{% endautoescape %}" + "autoescape-stringfilter04": ( + "{% autoescape off %}{{ safe|capfirst }}{% endautoescape %}" + ) } ) def test_autoescape_stringfilter04(self): diff --git a/tests/template_tests/filter_tests/test_capfirst.py b/tests/template_tests/filter_tests/test_capfirst.py index 3c489e6a1f..f835691ff8 100644 --- a/tests/template_tests/filter_tests/test_capfirst.py +++ b/tests/template_tests/filter_tests/test_capfirst.py @@ -8,7 +8,10 @@ from ..utils import setup class CapfirstTests(SimpleTestCase): @setup( { - "capfirst01": "{% autoescape off %}{{ a|capfirst }} {{ b|capfirst }}{% endautoescape %}" + "capfirst01": ( + "{% autoescape off %}{{ a|capfirst }} {{ b|capfirst }}" + "{% endautoescape %}" + ) } ) def test_capfirst01(self): diff --git a/tests/template_tests/filter_tests/test_center.py b/tests/template_tests/filter_tests/test_center.py index 0a18294d88..3aafa9f9bb 100644 --- a/tests/template_tests/filter_tests/test_center.py +++ b/tests/template_tests/filter_tests/test_center.py @@ -8,7 +8,10 @@ from ..utils import setup class CenterTests(SimpleTestCase): @setup( { - "center01": '{% autoescape off %}.{{ a|center:"5" }}. .{{ b|center:"5" }}.{% endautoescape %}' + "center01": ( + '{% autoescape off %}.{{ a|center:"5" }}. .{{ b|center:"5" }}.' + "{% endautoescape %}" + ) } ) def test_center01(self): diff --git a/tests/template_tests/filter_tests/test_chaining.py b/tests/template_tests/filter_tests/test_chaining.py index 942707820f..9b07942101 100644 --- a/tests/template_tests/filter_tests/test_chaining.py +++ b/tests/template_tests/filter_tests/test_chaining.py @@ -18,7 +18,10 @@ class ChainingTests(SimpleTestCase): @setup( { - "chaining02": '{% autoescape off %}{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"7" }}{% endautoescape %}' + "chaining02": ( + '{% autoescape off %}{{ a|capfirst|center:"7" }}.' + '{{ b|capfirst|center:"7" }}{% endautoescape %}' + ) } ) def test_chaining02(self): @@ -37,7 +40,10 @@ class ChainingTests(SimpleTestCase): @setup( { - "chaining04": '{% autoescape off %}{{ a|cut:"b"|capfirst }}.{{ b|cut:"b"|capfirst }}{% endautoescape %}' + "chaining04": ( + '{% autoescape off %}{{ a|cut:"b"|capfirst }}.{{ b|cut:"b"|capfirst }}' + "{% endautoescape %}" + ) } ) def test_chaining04(self): @@ -68,7 +74,9 @@ class ChainingTests(SimpleTestCase): @setup( { - "chaining08": '{% autoescape off %}{{ a|force_escape|cut:";" }}{% endautoescape %}' + "chaining08": ( + '{% autoescape off %}{{ a|force_escape|cut:";" }}{% endautoescape %}' + ) } ) def test_chaining08(self): @@ -82,7 +90,9 @@ class ChainingTests(SimpleTestCase): @setup( { - "chaining10": '{% autoescape off %}{{ a|cut:";"|force_escape }}{% endautoescape %}' + "chaining10": ( + '{% autoescape off %}{{ a|cut:";"|force_escape }}{% endautoescape %}' + ) } ) def test_chaining10(self): @@ -108,7 +118,9 @@ class ChainingTests(SimpleTestCase): @setup( { - "chaining14": "{% autoescape off %}{{ a|safe|force_escape }}{% endautoescape %}" + "chaining14": ( + "{% autoescape off %}{{ a|safe|force_escape }}{% endautoescape %}" + ) } ) def test_chaining14(self): diff --git a/tests/template_tests/filter_tests/test_cut.py b/tests/template_tests/filter_tests/test_cut.py index adf1468709..ea6129d84a 100644 --- a/tests/template_tests/filter_tests/test_cut.py +++ b/tests/template_tests/filter_tests/test_cut.py @@ -8,7 +8,9 @@ from ..utils import setup class CutTests(SimpleTestCase): @setup( { - "cut01": '{% autoescape off %}{{ a|cut:"x" }} {{ b|cut:"x" }}{% endautoescape %}' + "cut01": ( + '{% autoescape off %}{{ a|cut:"x" }} {{ b|cut:"x" }}{% endautoescape %}' + ) } ) def test_cut01(self): @@ -26,7 +28,9 @@ class CutTests(SimpleTestCase): @setup( { - "cut03": '{% autoescape off %}{{ a|cut:"&" }} {{ b|cut:"&" }}{% endautoescape %}' + "cut03": ( + '{% autoescape off %}{{ a|cut:"&" }} {{ b|cut:"&" }}{% endautoescape %}' + ) } ) def test_cut03(self): @@ -46,7 +50,9 @@ class CutTests(SimpleTestCase): # are auto-escaped. @setup( { - "cut05": '{% autoescape off %}{{ a|cut:";" }} {{ b|cut:";" }}{% endautoescape %}' + "cut05": ( + '{% autoescape off %}{{ a|cut:";" }} {{ b|cut:";" }}{% endautoescape %}' + ) } ) def test_cut05(self): diff --git a/tests/template_tests/filter_tests/test_default.py b/tests/template_tests/filter_tests/test_default.py index 20621f610f..c55f5ad948 100644 --- a/tests/template_tests/filter_tests/test_default.py +++ b/tests/template_tests/filter_tests/test_default.py @@ -43,7 +43,9 @@ class DefaultIfNoneTests(SimpleTestCase): @setup( { - "default_if_none02": '{% autoescape off %}{{ a|default:"x<" }}{% endautoescape %}' + "default_if_none02": ( + '{% autoescape off %}{{ a|default:"x<" }}{% endautoescape %}' + ) } ) def test_default_if_none02(self): diff --git a/tests/template_tests/filter_tests/test_escape.py b/tests/template_tests/filter_tests/test_escape.py index 16471ad53f..a8fe531645 100644 --- a/tests/template_tests/filter_tests/test_escape.py +++ b/tests/template_tests/filter_tests/test_escape.py @@ -21,7 +21,9 @@ class EscapeTests(SimpleTestCase): @setup( { - "escape02": "{% autoescape off %}{{ a|escape }} {{ b|escape }}{% endautoescape %}" + "escape02": ( + "{% autoescape off %}{{ a|escape }} {{ b|escape }}{% endautoescape %}" + ) } ) def test_escape02(self): diff --git a/tests/template_tests/filter_tests/test_first.py b/tests/template_tests/filter_tests/test_first.py index 7a1849cd88..224dec7b0f 100644 --- a/tests/template_tests/filter_tests/test_first.py +++ b/tests/template_tests/filter_tests/test_first.py @@ -15,7 +15,9 @@ class FirstTests(SimpleTestCase): @setup( { - "first02": "{% autoescape off %}{{ a|first }} {{ b|first }}{% endautoescape %}" + "first02": ( + "{% autoescape off %}{{ a|first }} {{ b|first }}{% endautoescape %}" + ) } ) def test_first02(self): diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py index d7eb5f2076..8dc69b2437 100644 --- a/tests/template_tests/filter_tests/test_floatformat.py +++ b/tests/template_tests/filter_tests/test_floatformat.py @@ -11,7 +11,10 @@ from ..utils import setup class FloatformatTests(SimpleTestCase): @setup( { - "floatformat01": "{% autoescape off %}{{ a|floatformat }} {{ b|floatformat }}{% endautoescape %}" + "floatformat01": ( + "{% autoescape off %}{{ a|floatformat }} {{ b|floatformat }}" + "{% endautoescape %}" + ) } ) def test_floatformat01(self): diff --git a/tests/template_tests/filter_tests/test_force_escape.py b/tests/template_tests/filter_tests/test_force_escape.py index 7a34caee2b..02a4063adc 100644 --- a/tests/template_tests/filter_tests/test_force_escape.py +++ b/tests/template_tests/filter_tests/test_force_escape.py @@ -13,7 +13,9 @@ class ForceEscapeTests(SimpleTestCase): @setup( { - "force-escape01": "{% autoescape off %}{{ a|force_escape }}{% endautoescape %}" + "force-escape01": ( + "{% autoescape off %}{{ a|force_escape }}{% endautoescape %}" + ) } ) def test_force_escape01(self): @@ -27,7 +29,10 @@ class ForceEscapeTests(SimpleTestCase): @setup( { - "force-escape03": "{% autoescape off %}{{ a|force_escape|force_escape }}{% endautoescape %}" + "force-escape03": ( + "{% autoescape off %}{{ a|force_escape|force_escape }}" + "{% endautoescape %}" + ) } ) def test_force_escape03(self): @@ -43,7 +48,9 @@ class ForceEscapeTests(SimpleTestCase): # escape filter has no effect. @setup( { - "force-escape05": "{% autoescape off %}{{ a|force_escape|escape }}{% endautoescape %}" + "force-escape05": ( + "{% autoescape off %}{{ a|force_escape|escape }}{% endautoescape %}" + ) } ) def test_force_escape05(self): @@ -57,7 +64,9 @@ class ForceEscapeTests(SimpleTestCase): @setup( { - "force-escape07": "{% autoescape off %}{{ a|escape|force_escape }}{% endautoescape %}" + "force-escape07": ( + "{% autoescape off %}{{ a|escape|force_escape }}{% endautoescape %}" + ) } ) def test_force_escape07(self): diff --git a/tests/template_tests/filter_tests/test_json_script.py b/tests/template_tests/filter_tests/test_json_script.py index 28a078effb..8b9d6556fe 100644 --- a/tests/template_tests/filter_tests/test_json_script.py +++ b/tests/template_tests/filter_tests/test_json_script.py @@ -12,7 +12,8 @@ class JsonScriptTests(SimpleTestCase): self.assertEqual( output, '<script id="test_id" type="application/json">' - '{"a": "testing\\r\\njson \'string\\" \\u003Cb\\u003Eescaping\\u003C/b\\u003E"}' + '{"a": "testing\\r\\njson \'string\\" ' + '\\u003Cb\\u003Eescaping\\u003C/b\\u003E"}' "</script>", ) diff --git a/tests/template_tests/filter_tests/test_length_is.py b/tests/template_tests/filter_tests/test_length_is.py index 1cc760c8a2..cbda46e5b1 100644 --- a/tests/template_tests/filter_tests/test_length_is.py +++ b/tests/template_tests/filter_tests/test_length_is.py @@ -14,7 +14,9 @@ class LengthIsTests(SimpleTestCase): @setup( { - "length_is02": '{% if some_list|length_is:"4" %}Four{% else %}Not Four{% endif %}' + "length_is02": ( + '{% if some_list|length_is:"4" %}Four{% else %}Not Four{% endif %}' + ) } ) def test_length_is02(self): @@ -30,7 +32,9 @@ class LengthIsTests(SimpleTestCase): @setup( { - "length_is04": '{% if mystring|length_is:"4" %}Four{% else %}Not Four{% endif %}' + "length_is04": ( + '{% if mystring|length_is:"4" %}Four{% else %}Not Four{% endif %}' + ) } ) def test_length_is04(self): @@ -39,7 +43,9 @@ class LengthIsTests(SimpleTestCase): @setup( { - "length_is05": '{% if mystring|length_is:"4" %}Four{% else %}Not Four{% endif %}' + "length_is05": ( + '{% if mystring|length_is:"4" %}Four{% else %}Not Four{% endif %}' + ) } ) def test_length_is05(self): @@ -48,7 +54,9 @@ class LengthIsTests(SimpleTestCase): @setup( { - "length_is06": "{% with var|length as my_length %}{{ my_length }}{% endwith %}" + "length_is06": ( + "{% with var|length as my_length %}{{ my_length }}{% endwith %}" + ) } ) def test_length_is06(self): @@ -58,7 +66,9 @@ class LengthIsTests(SimpleTestCase): # Boolean return value from length_is should not be coerced to a string @setup( { - "length_is07": '{% if "X"|length_is:0 %}Length is 0{% else %}Length not 0{% endif %}' + "length_is07": ( + '{% if "X"|length_is:0 %}Length is 0{% else %}Length not 0{% endif %}' + ) } ) def test_length_is07(self): @@ -67,7 +77,9 @@ class LengthIsTests(SimpleTestCase): @setup( { - "length_is08": '{% if "X"|length_is:1 %}Length is 1{% else %}Length not 1{% endif %}' + "length_is08": ( + '{% if "X"|length_is:1 %}Length is 1{% else %}Length not 1{% endif %}' + ) } ) def test_length_is08(self): diff --git a/tests/template_tests/filter_tests/test_linebreaks.py b/tests/template_tests/filter_tests/test_linebreaks.py index ce0f082466..10c8a92d6a 100644 --- a/tests/template_tests/filter_tests/test_linebreaks.py +++ b/tests/template_tests/filter_tests/test_linebreaks.py @@ -21,7 +21,10 @@ class LinebreaksTests(SimpleTestCase): @setup( { - "linebreaks02": "{% autoescape off %}{{ a|linebreaks }} {{ b|linebreaks }}{% endautoescape %}" + "linebreaks02": ( + "{% autoescape off %}{{ a|linebreaks }} {{ b|linebreaks }}" + "{% endautoescape %}" + ) } ) def test_linebreaks02(self): diff --git a/tests/template_tests/filter_tests/test_linebreaksbr.py b/tests/template_tests/filter_tests/test_linebreaksbr.py index fa4cff209b..aa6505a47a 100644 --- a/tests/template_tests/filter_tests/test_linebreaksbr.py +++ b/tests/template_tests/filter_tests/test_linebreaksbr.py @@ -20,7 +20,10 @@ class LinebreaksbrTests(SimpleTestCase): @setup( { - "linebreaksbr02": "{% autoescape off %}{{ a|linebreaksbr }} {{ b|linebreaksbr }}{% endautoescape %}" + "linebreaksbr02": ( + "{% autoescape off %}{{ a|linebreaksbr }} {{ b|linebreaksbr }}" + "{% endautoescape %}" + ) } ) def test_linebreaksbr02(self): diff --git a/tests/template_tests/filter_tests/test_linenumbers.py b/tests/template_tests/filter_tests/test_linenumbers.py index 82fae4f889..8b1f8ef8af 100644 --- a/tests/template_tests/filter_tests/test_linenumbers.py +++ b/tests/template_tests/filter_tests/test_linenumbers.py @@ -23,7 +23,10 @@ class LinenumbersTests(SimpleTestCase): @setup( { - "linenumbers02": "{% autoescape off %}{{ a|linenumbers }} {{ b|linenumbers }}{% endautoescape %}" + "linenumbers02": ( + "{% autoescape off %}{{ a|linenumbers }} {{ b|linenumbers }}" + "{% endautoescape %}" + ) } ) def test_linenumbers02(self): diff --git a/tests/template_tests/filter_tests/test_ljust.py b/tests/template_tests/filter_tests/test_ljust.py index 9ea5b23862..f07a3c88f7 100644 --- a/tests/template_tests/filter_tests/test_ljust.py +++ b/tests/template_tests/filter_tests/test_ljust.py @@ -8,7 +8,10 @@ from ..utils import setup class LjustTests(SimpleTestCase): @setup( { - "ljust01": '{% autoescape off %}.{{ a|ljust:"5" }}. .{{ b|ljust:"5" }}.{% endautoescape %}' + "ljust01": ( + '{% autoescape off %}.{{ a|ljust:"5" }}. .{{ b|ljust:"5" }}.' + "{% endautoescape %}" + ) } ) def test_ljust01(self): diff --git a/tests/template_tests/filter_tests/test_lower.py b/tests/template_tests/filter_tests/test_lower.py index 29845663dd..ae30094d69 100644 --- a/tests/template_tests/filter_tests/test_lower.py +++ b/tests/template_tests/filter_tests/test_lower.py @@ -8,7 +8,9 @@ from ..utils import setup class LowerTests(SimpleTestCase): @setup( { - "lower01": "{% autoescape off %}{{ a|lower }} {{ b|lower }}{% endautoescape %}" + "lower01": ( + "{% autoescape off %}{{ a|lower }} {{ b|lower }}{% endautoescape %}" + ) } ) def test_lower01(self): diff --git a/tests/template_tests/filter_tests/test_make_list.py b/tests/template_tests/filter_tests/test_make_list.py index 34901d2ff2..ddf8dbc7e7 100644 --- a/tests/template_tests/filter_tests/test_make_list.py +++ b/tests/template_tests/filter_tests/test_make_list.py @@ -23,7 +23,10 @@ class MakeListTests(SimpleTestCase): @setup( { - "make_list03": '{% autoescape off %}{{ a|make_list|stringformat:"s"|safe }}{% endautoescape %}' + "make_list03": ( + '{% autoescape off %}{{ a|make_list|stringformat:"s"|safe }}' + "{% endautoescape %}" + ) } ) def test_make_list03(self): diff --git a/tests/template_tests/filter_tests/test_phone2numeric.py b/tests/template_tests/filter_tests/test_phone2numeric.py index 8165fba9da..ee3805b70d 100644 --- a/tests/template_tests/filter_tests/test_phone2numeric.py +++ b/tests/template_tests/filter_tests/test_phone2numeric.py @@ -16,7 +16,10 @@ class Phone2numericTests(SimpleTestCase): @setup( { - "phone2numeric02": "{% autoescape off %}{{ a|phone2numeric }} {{ b|phone2numeric }}{% endautoescape %}" + "phone2numeric02": ( + "{% autoescape off %}{{ a|phone2numeric }} {{ b|phone2numeric }}" + "{% endautoescape %}" + ) } ) def test_phone2numeric02(self): diff --git a/tests/template_tests/filter_tests/test_random.py b/tests/template_tests/filter_tests/test_random.py index a419128971..785f2d6a2f 100644 --- a/tests/template_tests/filter_tests/test_random.py +++ b/tests/template_tests/filter_tests/test_random.py @@ -14,7 +14,9 @@ class RandomTests(SimpleTestCase): @setup( { - "random02": "{% autoescape off %}{{ a|random }} {{ b|random }}{% endautoescape %}" + "random02": ( + "{% autoescape off %}{{ a|random }} {{ b|random }}{% endautoescape %}" + ) } ) def test_random02(self): diff --git a/tests/template_tests/filter_tests/test_rjust.py b/tests/template_tests/filter_tests/test_rjust.py index b7dde7514a..2d12dfccf4 100644 --- a/tests/template_tests/filter_tests/test_rjust.py +++ b/tests/template_tests/filter_tests/test_rjust.py @@ -8,7 +8,10 @@ from ..utils import setup class RjustTests(SimpleTestCase): @setup( { - "rjust01": '{% autoescape off %}.{{ a|rjust:"5" }}. .{{ b|rjust:"5" }}.{% endautoescape %}' + "rjust01": ( + '{% autoescape off %}.{{ a|rjust:"5" }}. .{{ b|rjust:"5" }}.' + "{% endautoescape %}" + ) } ) def test_rjust01(self): diff --git a/tests/template_tests/filter_tests/test_safeseq.py b/tests/template_tests/filter_tests/test_safeseq.py index 4a537551f9..e9b3feb0b3 100644 --- a/tests/template_tests/filter_tests/test_safeseq.py +++ b/tests/template_tests/filter_tests/test_safeseq.py @@ -11,7 +11,10 @@ class SafeseqTests(SimpleTestCase): @setup( { - "safeseq02": '{% autoescape off %}{{ a|join:", " }} -- {{ a|safeseq|join:", " }}{% endautoescape %}' + "safeseq02": ( + '{% autoescape off %}{{ a|join:", " }} -- {{ a|safeseq|join:", " }}' + "{% endautoescape %}" + ) } ) def test_safeseq02(self): diff --git a/tests/template_tests/filter_tests/test_slice.py b/tests/template_tests/filter_tests/test_slice.py index f1c91a5008..5a5dd6b155 100644 --- a/tests/template_tests/filter_tests/test_slice.py +++ b/tests/template_tests/filter_tests/test_slice.py @@ -15,7 +15,10 @@ class SliceTests(SimpleTestCase): @setup( { - "slice02": '{% autoescape off %}{{ a|slice:"1:3" }} {{ b|slice:"1:3" }}{% endautoescape %}' + "slice02": ( + '{% autoescape off %}{{ a|slice:"1:3" }} {{ b|slice:"1:3" }}' + "{% endautoescape %}" + ) } ) def test_slice02(self): diff --git a/tests/template_tests/filter_tests/test_slugify.py b/tests/template_tests/filter_tests/test_slugify.py index e0e8a52da9..7bb18c5c89 100644 --- a/tests/template_tests/filter_tests/test_slugify.py +++ b/tests/template_tests/filter_tests/test_slugify.py @@ -14,7 +14,9 @@ class SlugifyTests(SimpleTestCase): @setup( { - "slugify01": "{% autoescape off %}{{ a|slugify }} {{ b|slugify }}{% endautoescape %}" + "slugify01": ( + "{% autoescape off %}{{ a|slugify }} {{ b|slugify }}{% endautoescape %}" + ) } ) def test_slugify01(self): diff --git a/tests/template_tests/filter_tests/test_stringformat.py b/tests/template_tests/filter_tests/test_stringformat.py index e8f06ac4a0..075906aecb 100644 --- a/tests/template_tests/filter_tests/test_stringformat.py +++ b/tests/template_tests/filter_tests/test_stringformat.py @@ -13,7 +13,10 @@ class StringformatTests(SimpleTestCase): @setup( { - "stringformat01": '{% autoescape off %}.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.{% endautoescape %}' + "stringformat01": ( + '{% autoescape off %}.{{ a|stringformat:"5s" }}. .' + '{{ b|stringformat:"5s" }}.{% endautoescape %}' + ) } ) def test_stringformat01(self): diff --git a/tests/template_tests/filter_tests/test_striptags.py b/tests/template_tests/filter_tests/test_striptags.py index 7b142f5379..235a35b43e 100644 --- a/tests/template_tests/filter_tests/test_striptags.py +++ b/tests/template_tests/filter_tests/test_striptags.py @@ -20,7 +20,10 @@ class StriptagsTests(SimpleTestCase): @setup( { - "striptags02": "{% autoescape off %}{{ a|striptags }} {{ b|striptags }}{% endautoescape %}" + "striptags02": ( + "{% autoescape off %}{{ a|striptags }} {{ b|striptags }}" + "{% endautoescape %}" + ) } ) def test_striptags02(self): @@ -38,7 +41,8 @@ class FunctionTests(SimpleTestCase): def test_strip(self): self.assertEqual( striptags( - 'some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags' + 'some <b>html</b> with <script>alert("You smell")</script> disallowed ' + "<img /> tags" ), 'some html with alert("You smell") disallowed tags', ) @@ -50,7 +54,8 @@ class FunctionTests(SimpleTestCase): self.assertEqual( striptags( lazystr( - 'some <b>html</b> with <script>alert("Hello")</script> disallowed <img /> tags' + 'some <b>html</b> with <script>alert("Hello")</script> disallowed ' + "<img /> tags" ) ), 'some html with alert("Hello") disallowed tags', diff --git a/tests/template_tests/filter_tests/test_truncatewords.py b/tests/template_tests/filter_tests/test_truncatewords.py index b3457205ac..e737a1e3f9 100644 --- a/tests/template_tests/filter_tests/test_truncatewords.py +++ b/tests/template_tests/filter_tests/test_truncatewords.py @@ -8,7 +8,10 @@ from ..utils import setup class TruncatewordsTests(SimpleTestCase): @setup( { - "truncatewords01": '{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}{% endautoescape %}' + "truncatewords01": ( + '{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}' + "{% endautoescape %}" + ) } ) def test_truncatewords01(self): diff --git a/tests/template_tests/filter_tests/test_unordered_list.py b/tests/template_tests/filter_tests/test_unordered_list.py index 1f08ea790d..1748a0fb54 100644 --- a/tests/template_tests/filter_tests/test_unordered_list.py +++ b/tests/template_tests/filter_tests/test_unordered_list.py @@ -16,7 +16,9 @@ class UnorderedListTests(SimpleTestCase): @setup( { - "unordered_list02": "{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}" + "unordered_list02": ( + "{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}" + ) } ) def test_unordered_list02(self): @@ -34,7 +36,9 @@ class UnorderedListTests(SimpleTestCase): @setup( { - "unordered_list04": "{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}" + "unordered_list04": ( + "{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}" + ) } ) def test_unordered_list04(self): @@ -45,7 +49,9 @@ class UnorderedListTests(SimpleTestCase): @setup( { - "unordered_list05": "{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}" + "unordered_list05": ( + "{% autoescape off %}{{ a|unordered_list }}{% endautoescape %}" + ) } ) def test_unordered_list05(self): @@ -126,7 +132,8 @@ class FunctionTests(SimpleTestCase): c = ULItem("<a>c</a>") self.assertEqual( unordered_list([a, b, c]), - "\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>\n\t<li>ulitem-<a>c</a></li>", + "\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>\n\t" + "<li>ulitem-<a>c</a></li>", ) def item_generator(): @@ -134,7 +141,8 @@ class FunctionTests(SimpleTestCase): self.assertEqual( unordered_list(item_generator()), - "\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>\n\t<li>ulitem-<a>c</a></li>", + "\t<li>ulitem-a</li>\n\t<li>ulitem-b</li>\n\t" + "<li>ulitem-<a>c</a></li>", ) def test_nested_generators(self): @@ -148,7 +156,8 @@ class FunctionTests(SimpleTestCase): self.assertEqual( unordered_list(item_generator()), - "\t<li>A\n\t<ul>\n\t\t<li>B</li>\n\t\t<li>C</li>\n\t</ul>\n\t</li>\n\t<li>D</li>", + "\t<li>A\n\t<ul>\n\t\t<li>B</li>\n\t\t<li>C</li>\n\t</ul>\n\t</li>\n\t" + "<li>D</li>", ) def test_ulitem_autoescape_off(self): diff --git a/tests/template_tests/filter_tests/test_upper.py b/tests/template_tests/filter_tests/test_upper.py index 01a2f306ae..90f14a794a 100644 --- a/tests/template_tests/filter_tests/test_upper.py +++ b/tests/template_tests/filter_tests/test_upper.py @@ -13,7 +13,9 @@ class UpperTests(SimpleTestCase): @setup( { - "upper01": "{% autoescape off %}{{ a|upper }} {{ b|upper }}{% endautoescape %}" + "upper01": ( + "{% autoescape off %}{{ a|upper }} {{ b|upper }}{% endautoescape %}" + ) } ) def test_upper01(self): diff --git a/tests/template_tests/filter_tests/test_urlize.py b/tests/template_tests/filter_tests/test_urlize.py index 01e97b35fc..abc227ba6a 100644 --- a/tests/template_tests/filter_tests/test_urlize.py +++ b/tests/template_tests/filter_tests/test_urlize.py @@ -9,7 +9,9 @@ from ..utils import setup class UrlizeTests(SimpleTestCase): @setup( { - "urlize01": "{% autoescape off %}{{ a|urlize }} {{ b|urlize }}{% endautoescape %}" + "urlize01": ( + "{% autoescape off %}{{ a|urlize }} {{ b|urlize }}{% endautoescape %}" + ) } ) def test_urlize01(self): @@ -22,8 +24,10 @@ class UrlizeTests(SimpleTestCase): ) self.assertEqual( output, - '<a href="http://example.com/?x=&y=" rel="nofollow">http://example.com/?x=&y=</a> ' - '<a href="http://example.com?x=&y=%3C2%3E" rel="nofollow">http://example.com?x=&y=<2></a>', + '<a href="http://example.com/?x=&y=" rel="nofollow">' + "http://example.com/?x=&y=</a> " + '<a href="http://example.com?x=&y=%3C2%3E" rel="nofollow">' + "http://example.com?x=&y=<2></a>", ) @setup({"urlize02": "{{ a|urlize }} {{ b|urlize }}"}) @@ -37,8 +41,10 @@ class UrlizeTests(SimpleTestCase): ) self.assertEqual( output, - '<a href="http://example.com/?x=&y=" rel="nofollow">http://example.com/?x=&y=</a> ' - '<a href="http://example.com?x=&y=" rel="nofollow">http://example.com?x=&y=</a>', + '<a href="http://example.com/?x=&y=" rel="nofollow">' + "http://example.com/?x=&y=</a> " + '<a href="http://example.com?x=&y=" rel="nofollow">' + "http://example.com?x=&y=</a>", ) @setup({"urlize03": "{% autoescape off %}{{ a|urlize }}{% endautoescape %}"}) @@ -95,7 +101,8 @@ class UrlizeTests(SimpleTestCase): ) self.assertEqual( output, - '<a href="http://example.com/?x=&y=%3C2%3E" rel="nofollow">http://example.com/?x=&y=<2></a>', + '<a href="http://example.com/?x=&y=%3C2%3E" rel="nofollow">' + "http://example.com/?x=&y=<2></a>", ) @@ -127,11 +134,13 @@ class FunctionTests(SimpleTestCase): # part of URLs. self.assertEqual( urlize('www.server.com"abc'), - '<a href="http://www.server.com" rel="nofollow">www.server.com</a>"abc', + '<a href="http://www.server.com" rel="nofollow">www.server.com</a>"' + "abc", ) self.assertEqual( urlize("www.server.com'abc"), - '<a href="http://www.server.com" rel="nofollow">www.server.com</a>'abc', + '<a href="http://www.server.com" rel="nofollow">www.server.com</a>'' + "abc", ) self.assertEqual( urlize("www.server.com<abc"), @@ -164,8 +173,9 @@ class FunctionTests(SimpleTestCase): """ self.assertEqual( urlize("http://hi.baidu.com/%E9%87%8D%E6%96%B0%E5%BC%80%E5%A7%8B"), - '<a href="http://hi.baidu.com/%E9%87%8D%E6%96%B0%E5%BC%80%E5%A7%8B" rel="nofollow">' - "http://hi.baidu.com/%E9%87%8D%E6%96%B0%E5%BC%80%E5%A7%8B</a>", + '<a href="http://hi.baidu.com/%E9%87%8D%E6%96%B0%E5%BC%80%E5%A7%8B" ' + 'rel="nofollow">http://hi.baidu.com/%E9%87%8D%E6%96%B0%E5%BC%80%E5%A7%8B' + "</a>", ) def test_urlencoded(self): @@ -193,13 +203,13 @@ class FunctionTests(SimpleTestCase): """ self.assertEqual( urlize("https://en.wikipedia.org/wiki/Django_(web_framework)"), - '<a href="https://en.wikipedia.org/wiki/Django_(web_framework)" rel="nofollow">' - "https://en.wikipedia.org/wiki/Django_(web_framework)</a>", + '<a href="https://en.wikipedia.org/wiki/Django_(web_framework)" ' + 'rel="nofollow">https://en.wikipedia.org/wiki/Django_(web_framework)</a>', ) self.assertEqual( urlize("(see https://en.wikipedia.org/wiki/Django_(web_framework))"), - '(see <a href="https://en.wikipedia.org/wiki/Django_(web_framework)" rel="nofollow">' - "https://en.wikipedia.org/wiki/Django_(web_framework)</a>)", + '(see <a href="https://en.wikipedia.org/wiki/Django_(web_framework)" ' + 'rel="nofollow">https://en.wikipedia.org/wiki/Django_(web_framework)</a>)', ) def test_nofollow(self): @@ -269,25 +279,30 @@ class FunctionTests(SimpleTestCase): """ self.assertEqual( urlize("(Go to http://www.example.com/foo.)"), - '(Go to <a href="http://www.example.com/foo" rel="nofollow">http://www.example.com/foo</a>.)', + '(Go to <a href="http://www.example.com/foo" rel="nofollow">' + "http://www.example.com/foo</a>.)", ) def test_trailing_multiple_punctuation(self): self.assertEqual( urlize("A test http://testing.com/example.."), - 'A test <a href="http://testing.com/example" rel="nofollow">http://testing.com/example</a>..', + 'A test <a href="http://testing.com/example" rel="nofollow">' + "http://testing.com/example</a>..", ) self.assertEqual( urlize("A test http://testing.com/example!!"), - 'A test <a href="http://testing.com/example" rel="nofollow">http://testing.com/example</a>!!', + 'A test <a href="http://testing.com/example" rel="nofollow">' + "http://testing.com/example</a>!!", ) self.assertEqual( urlize("A test http://testing.com/example!!!"), - 'A test <a href="http://testing.com/example" rel="nofollow">http://testing.com/example</a>!!!', + 'A test <a href="http://testing.com/example" rel="nofollow">' + "http://testing.com/example</a>!!!", ) self.assertEqual( urlize('A test http://testing.com/example.,:;)"!'), - 'A test <a href="http://testing.com/example" rel="nofollow">http://testing.com/example</a>.,:;)"!', + 'A test <a href="http://testing.com/example" rel="nofollow">' + "http://testing.com/example</a>.,:;)"!", ) def test_brackets(self): @@ -300,7 +315,8 @@ class FunctionTests(SimpleTestCase): ) self.assertEqual( urlize("see test[at[example.com"), - 'see <a href="http://test[at[example.com" rel="nofollow">test[at[example.com</a>', + 'see <a href="http://test[at[example.com" rel="nofollow">' + "test[at[example.com</a>", ) self.assertEqual( urlize("[http://168.192.0.1](http://168.192.0.1)"), @@ -321,21 +337,22 @@ class FunctionTests(SimpleTestCase): start_in, end_in = wrapping_in self.assertEqual( urlize(start_in + "https://www.example.org/" + end_in), - start_out - + '<a href="https://www.example.org/" rel="nofollow">https://www.example.org/</a>' - + end_out, + f'{start_out}<a href="https://www.example.org/" rel="nofollow">' + f"https://www.example.org/</a>{end_out}", ) def test_ipv4(self): self.assertEqual( urlize("http://192.168.0.15/api/9"), - '<a href="http://192.168.0.15/api/9" rel="nofollow">http://192.168.0.15/api/9</a>', + '<a href="http://192.168.0.15/api/9" rel="nofollow">' + "http://192.168.0.15/api/9</a>", ) def test_ipv6(self): self.assertEqual( urlize("http://[2001:db8:cafe::2]/api/9"), - '<a href="http://[2001:db8:cafe::2]/api/9" rel="nofollow">http://[2001:db8:cafe::2]/api/9</a>', + '<a href="http://[2001:db8:cafe::2]/api/9" rel="nofollow">' + "http://[2001:db8:cafe::2]/api/9</a>", ) def test_quotation_marks(self): @@ -375,7 +392,8 @@ class FunctionTests(SimpleTestCase): urlize( 'Email us at "hi@example.com", or phone us at +xx.yy', autoescape=False ), - 'Email us at "<a href="mailto:hi@example.com">hi@example.com</a>", or phone us at +xx.yy', + 'Email us at "<a href="mailto:hi@example.com">hi@example.com</a>", or ' + "phone us at +xx.yy", ) def test_exclamation_marks(self): @@ -385,19 +403,23 @@ class FunctionTests(SimpleTestCase): """ self.assertEqual( urlize("Go to djangoproject.com! and enjoy."), - 'Go to <a href="http://djangoproject.com" rel="nofollow">djangoproject.com</a>! and enjoy.', + 'Go to <a href="http://djangoproject.com" rel="nofollow">djangoproject.com' + "</a>! and enjoy.", ) self.assertEqual( urlize("Search for google.com/?q=! and see."), - 'Search for <a href="http://google.com/?q=" rel="nofollow">google.com/?q=</a>! and see.', + 'Search for <a href="http://google.com/?q=" rel="nofollow">google.com/?q=' + "</a>! and see.", ) self.assertEqual( urlize("Search for google.com/?q=dj!`? and see."), - 'Search for <a href="http://google.com/?q=dj%21%60%3F" rel="nofollow">google.com/?q=dj!`?</a> and see.', + 'Search for <a href="http://google.com/?q=dj%21%60%3F" rel="nofollow">' + "google.com/?q=dj!`?</a> and see.", ) self.assertEqual( urlize("Search for google.com/?q=dj!`?! and see."), - 'Search for <a href="http://google.com/?q=dj%21%60%3F" rel="nofollow">google.com/?q=dj!`?</a>! and see.', + 'Search for <a href="http://google.com/?q=dj%21%60%3F" rel="nofollow">' + "google.com/?q=dj!`?</a>! and see.", ) def test_non_string_input(self): @@ -406,13 +428,15 @@ class FunctionTests(SimpleTestCase): def test_autoescape(self): self.assertEqual( urlize('foo<a href=" google.com ">bar</a>buz'), - 'foo<a href=" <a href="http://google.com" rel="nofollow">google.com</a> ">bar</a>buz', + 'foo<a href=" <a href="http://google.com" rel="nofollow">google.com' + "</a> ">bar</a>buz", ) def test_autoescape_off(self): self.assertEqual( urlize('foo<a href=" google.com ">bar</a>buz', autoescape=False), - 'foo<a href=" <a href="http://google.com" rel="nofollow">google.com</a> ">bar</a>buz', + 'foo<a href=" <a href="http://google.com" rel="nofollow">google.com</a> ">' + "bar</a>buz", ) def test_lazystring(self): diff --git a/tests/template_tests/filter_tests/test_urlizetrunc.py b/tests/template_tests/filter_tests/test_urlizetrunc.py index 69e4ec4741..752ee3571e 100644 --- a/tests/template_tests/filter_tests/test_urlizetrunc.py +++ b/tests/template_tests/filter_tests/test_urlizetrunc.py @@ -8,7 +8,10 @@ from ..utils import setup class UrlizetruncTests(SimpleTestCase): @setup( { - "urlizetrunc01": '{% autoescape off %}{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}{% endautoescape %}' + "urlizetrunc01": ( + '{% autoescape off %}{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}' + "{% endautoescape %}" + ) } ) def test_urlizetrunc01(self): @@ -21,8 +24,10 @@ class UrlizetruncTests(SimpleTestCase): ) self.assertEqual( output, - '"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">http://…</a> ' - '"Safe" <a href="http://example.com?x=&y=" rel="nofollow">http://…</a>', + '"Unsafe" ' + '<a href="http://example.com/x=&y=" rel="nofollow">http://…</a> ' + ""Safe" " + '<a href="http://example.com?x=&y=" rel="nofollow">http://…</a>', ) @setup({"urlizetrunc02": '{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}'}) @@ -36,8 +41,10 @@ class UrlizetruncTests(SimpleTestCase): ) self.assertEqual( output, - '"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">http://…</a> ' - '"Safe" <a href="http://example.com?x=&y=" rel="nofollow">http://…</a>', + '"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">' + "http://…</a> " + '"Safe" <a href="http://example.com?x=&y=" rel="nofollow">' + "http://…</a>", ) @@ -72,11 +79,12 @@ class FunctionTests(SimpleTestCase): def test_query_string(self): self.assertEqual( urlizetrunc( - "http://www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search&meta=", + "http://www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search" + "&meta=", 20, ), - '<a href="http://www.google.co.uk/search?hl=en&q=some+long+url&btnG=Search&' - 'meta=" rel="nofollow">http://www.google.c…</a>', + '<a href="http://www.google.co.uk/search?hl=en&q=some+long+url&' + 'btnG=Search&meta=" rel="nofollow">http://www.google.c…</a>', ) def test_non_string_input(self): @@ -85,11 +93,13 @@ class FunctionTests(SimpleTestCase): def test_autoescape(self): self.assertEqual( urlizetrunc('foo<a href=" google.com ">bar</a>buz', 10), - 'foo<a href=" <a href="http://google.com" rel="nofollow">google.com</a> ">bar</a>buz', + 'foo<a href=" <a href="http://google.com" rel="nofollow">google.com' + "</a> ">bar</a>buz", ) def test_autoescape_off(self): self.assertEqual( urlizetrunc('foo<a href=" google.com ">bar</a>buz', 9, autoescape=False), - 'foo<a href=" <a href="http://google.com" rel="nofollow">google.c…</a> ">bar</a>buz', + 'foo<a href=" <a href="http://google.com" rel="nofollow">google.c…</a> ">' + "bar</a>buz", ) diff --git a/tests/template_tests/filter_tests/test_wordcount.py b/tests/template_tests/filter_tests/test_wordcount.py index d15447086f..d3a1eb05f1 100644 --- a/tests/template_tests/filter_tests/test_wordcount.py +++ b/tests/template_tests/filter_tests/test_wordcount.py @@ -8,7 +8,10 @@ from ..utils import setup class WordcountTests(SimpleTestCase): @setup( { - "wordcount01": "{% autoescape off %}{{ a|wordcount }} {{ b|wordcount }}{% endautoescape %}" + "wordcount01": ( + "{% autoescape off %}{{ a|wordcount }} {{ b|wordcount }}" + "{% endautoescape %}" + ) } ) def test_wordcount01(self): diff --git a/tests/template_tests/filter_tests/test_wordwrap.py b/tests/template_tests/filter_tests/test_wordwrap.py index fb2bce5a90..88fbd274da 100644 --- a/tests/template_tests/filter_tests/test_wordwrap.py +++ b/tests/template_tests/filter_tests/test_wordwrap.py @@ -9,7 +9,10 @@ from ..utils import setup class WordwrapTests(SimpleTestCase): @setup( { - "wordwrap01": '{% autoescape off %}{{ a|wordwrap:"3" }} {{ b|wordwrap:"3" }}{% endautoescape %}' + "wordwrap01": ( + '{% autoescape off %}{{ a|wordwrap:"3" }} {{ b|wordwrap:"3" }}' + "{% endautoescape %}" + ) } ) def test_wordwrap01(self): @@ -30,28 +33,34 @@ class FunctionTests(SimpleTestCase): def test_wrap(self): self.assertEqual( wordwrap( - "this is a long paragraph of text that really needs to be wrapped I'm afraid", + "this is a long paragraph of text that really needs to be wrapped I'm " + "afraid", 14, ), - "this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid", + "this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\n" + "I'm afraid", ) def test_indent(self): self.assertEqual( wordwrap( - "this is a short paragraph of text.\n But this line should be indented", + "this is a short paragraph of text.\n But this line should be " + "indented", 14, ), - "this is a\nshort\nparagraph of\ntext.\n But this\nline should be\nindented", + "this is a\nshort\nparagraph of\ntext.\n But this\nline should be\n" + "indented", ) def test_indent2(self): self.assertEqual( wordwrap( - "this is a short paragraph of text.\n But this line should be indented", + "this is a short paragraph of text.\n But this line should be " + "indented", 15, ), - "this is a short\nparagraph of\ntext.\n But this line\nshould be\nindented", + "this is a short\nparagraph of\ntext.\n But this line\nshould be\n" + "indented", ) def test_non_string_input(self): @@ -61,9 +70,11 @@ class FunctionTests(SimpleTestCase): self.assertEqual( wordwrap( lazystr( - "this is a long paragraph of text that really needs to be wrapped I'm afraid" + "this is a long paragraph of text that really needs to be wrapped " + "I'm afraid" ), 14, ), - "this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid", + "this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\n" + "I'm afraid", ) 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"ed.html" %}' + "static-statictag05": ( + '{% load static %}{% static "special?chars"ed.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): diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py index f9e457bbc1..c4455e4fa4 100644 --- a/tests/template_tests/templatetags/inclusion.py +++ b/tests/template_tests/templatetags/inclusion.py @@ -75,7 +75,9 @@ inclusion_explicit_no_context_from_template.anything = ( def inclusion_no_params_with_context(context): """Expected inclusion_no_params_with_context __doc__""" return { - "result": "inclusion_no_params_with_context - Expected result (context value: %s)" + "result": ( + "inclusion_no_params_with_context - Expected result (context value: %s)" + ) % context["value"] } @@ -90,9 +92,10 @@ def inclusion_no_params_with_context_from_template(context): """Expected inclusion_no_params_with_context_from_template __doc__""" return { "result": ( - "inclusion_no_params_with_context_from_template - Expected result (context value: %s)" - % context["value"] + "inclusion_no_params_with_context_from_template - Expected result (context " + "value: %s)" ) + % context["value"] } @@ -105,7 +108,9 @@ inclusion_no_params_with_context_from_template.anything = ( def inclusion_params_and_context(context, arg): """Expected inclusion_params_and_context __doc__""" return { - "result": "inclusion_params_and_context - Expected result (context value: %s): %s" + "result": ( + "inclusion_params_and_context - Expected result (context value: %s): %s" + ) % (context["value"], arg) } diff --git a/tests/template_tests/test_custom.py b/tests/template_tests/test_custom.py index acfb6890a5..1697d16ef5 100644 --- a/tests/template_tests/test_custom.py +++ b/tests/template_tests/test_custom.py @@ -111,8 +111,11 @@ class SimpleTagTests(TagTestCase): "simple_only_unlimited_args - Expected result: 37, 42, 56, 89", ), ( - '{% load custom %}{% simple_unlimited_args_kwargs 37 40|add:2 56 eggs="scrambled" four=1|add:3 %}', - "simple_unlimited_args_kwargs - Expected result: 37, 42, 56 / eggs=scrambled, four=4", + "{% load custom %}" + '{% simple_unlimited_args_kwargs 37 40|add:2 56 eggs="scrambled" ' + "four=1|add:3 %}", + "simple_unlimited_args_kwargs - Expected result: 37, 42, 56 / " + "eggs=scrambled, four=4", ), ] @@ -141,7 +144,8 @@ class SimpleTagTests(TagTestCase): "{% load custom %}{% simple_one_default 37 42 56 %}", ), ( - "'simple_keyword_only_param' did not receive value(s) for the argument(s): 'kwarg'", + "'simple_keyword_only_param' did not receive value(s) for the " + "argument(s): 'kwarg'", "{% load custom %}{% simple_keyword_only_param %}", ), ( @@ -156,12 +160,18 @@ class SimpleTagTests(TagTestCase): "kwarg=37 %}", ), ( - "'simple_unlimited_args_kwargs' received some positional argument(s) after some keyword argument(s)", - '{% load custom %}{% simple_unlimited_args_kwargs 37 40|add:2 eggs="scrambled" 56 four=1|add:3 %}', + "'simple_unlimited_args_kwargs' received some positional argument(s) " + "after some keyword argument(s)", + "{% load custom %}" + "{% simple_unlimited_args_kwargs 37 40|add:2 " + 'eggs="scrambled" 56 four=1|add:3 %}', ), ( - "'simple_unlimited_args_kwargs' received multiple values for keyword argument 'eggs'", - '{% load custom %}{% simple_unlimited_args_kwargs 37 eggs="scrambled" eggs="scrambled" %}', + "'simple_unlimited_args_kwargs' received multiple values for keyword " + "argument 'eggs'", + "{% load custom %}" + "{% simple_unlimited_args_kwargs 37 " + 'eggs="scrambled" eggs="scrambled" %}', ), ] @@ -252,11 +262,13 @@ class InclusionTagTests(TagTestCase): ), ( "{% load inclusion %}{% inclusion_no_params_with_context %}", - "inclusion_no_params_with_context - Expected result (context value: 42)\n", + "inclusion_no_params_with_context - Expected result (context value: " + "42)\n", ), ( "{% load inclusion %}{% inclusion_params_and_context 37 %}", - "inclusion_params_and_context - Expected result (context value: 42): 37\n", + "inclusion_params_and_context - Expected result (context value: 42): " + "37\n", ), ( "{% load inclusion %}{% inclusion_two_params 37 42 %}", @@ -299,8 +311,11 @@ class InclusionTagTests(TagTestCase): "inclusion_only_unlimited_args - Expected result: 37, 42, 56, 89\n", ), ( - '{% load inclusion %}{% inclusion_unlimited_args_kwargs 37 40|add:2 56 eggs="scrambled" four=1|add:3 %}', - "inclusion_unlimited_args_kwargs - Expected result: 37, 42, 56 / eggs=scrambled, four=4\n", + "{% load inclusion %}" + '{% inclusion_unlimited_args_kwargs 37 40|add:2 56 eggs="scrambled" ' + "four=1|add:3 %}", + "inclusion_unlimited_args_kwargs - Expected result: 37, 42, 56 / " + "eggs=scrambled, four=4\n", ), ] @@ -312,7 +327,8 @@ class InclusionTagTests(TagTestCase): errors = [ ( "'inclusion_one_default' received unexpected keyword argument 'three'", - '{% load inclusion %}{% inclusion_one_default 99 two="hello" three="foo" %}', + "{% load inclusion %}" + '{% inclusion_one_default 99 two="hello" three="foo" %}', ), ( "'inclusion_two_params' received too many positional arguments", @@ -323,7 +339,8 @@ class InclusionTagTests(TagTestCase): "{% load inclusion %}{% inclusion_one_default 37 42 56 %}", ), ( - "'inclusion_one_default' did not receive value(s) for the argument(s): 'one'", + "'inclusion_one_default' did not receive value(s) for the argument(s): " + "'one'", "{% load inclusion %}{% inclusion_one_default %}", ), ( @@ -333,17 +350,23 @@ class InclusionTagTests(TagTestCase): "kwarg=37 kwarg=42 %}", ), ( - "'inclusion_unlimited_args' did not receive value(s) for the argument(s): 'one'", + "'inclusion_unlimited_args' did not receive value(s) for the " + "argument(s): 'one'", "{% load inclusion %}{% inclusion_unlimited_args %}", ), ( - "'inclusion_unlimited_args_kwargs' received some positional argument(s) " - "after some keyword argument(s)", - '{% load inclusion %}{% inclusion_unlimited_args_kwargs 37 40|add:2 eggs="boiled" 56 four=1|add:3 %}', + "'inclusion_unlimited_args_kwargs' received some positional " + "argument(s) after some keyword argument(s)", + "{% load inclusion %}" + "{% inclusion_unlimited_args_kwargs 37 40|add:2 " + 'eggs="boiled" 56 four=1|add:3 %}', ), ( - "'inclusion_unlimited_args_kwargs' received multiple values for keyword argument 'eggs'", - '{% load inclusion %}{% inclusion_unlimited_args_kwargs 37 eggs="scrambled" eggs="scrambled" %}', + "'inclusion_unlimited_args_kwargs' received multiple values for " + "keyword argument 'eggs'", + "{% load inclusion %}" + "{% inclusion_unlimited_args_kwargs 37 " + 'eggs="scrambled" eggs="scrambled" %}', ), ] @@ -385,16 +408,21 @@ class InclusionTagTests(TagTestCase): "inclusion_one_param_from_template - Expected result: 37\n", ), ( - "{% load inclusion %}{% inclusion_explicit_no_context_from_template 37 %}", + "{% load inclusion %}" + "{% inclusion_explicit_no_context_from_template 37 %}", "inclusion_explicit_no_context_from_template - Expected result: 37\n", ), ( - "{% load inclusion %}{% inclusion_no_params_with_context_from_template %}", - "inclusion_no_params_with_context_from_template - Expected result (context value: 42)\n", + "{% load inclusion %}" + "{% inclusion_no_params_with_context_from_template %}", + "inclusion_no_params_with_context_from_template - Expected result " + "(context value: 42)\n", ), ( - "{% load inclusion %}{% inclusion_params_and_context_from_template 37 %}", - "inclusion_params_and_context_from_template - Expected result (context value: 42): 37\n", + "{% load inclusion %}" + "{% inclusion_params_and_context_from_template 37 %}", + "inclusion_params_and_context_from_template - Expected result (context " + "value: 42): 37\n", ), ( "{% load inclusion %}{% inclusion_two_params_from_template 37 42 %}", @@ -413,16 +441,20 @@ class InclusionTagTests(TagTestCase): "inclusion_unlimited_args_from_template - Expected result: 37, hi\n", ), ( - "{% load inclusion %}{% inclusion_unlimited_args_from_template 37 42 56 89 %}", - "inclusion_unlimited_args_from_template - Expected result: 37, 42, 56, 89\n", + "{% load inclusion %}" + "{% inclusion_unlimited_args_from_template 37 42 56 89 %}", + "inclusion_unlimited_args_from_template - Expected result: 37, 42, 56, " + "89\n", ), ( "{% load inclusion %}{% inclusion_only_unlimited_args_from_template %}", "inclusion_only_unlimited_args_from_template - Expected result: \n", ), ( - "{% load inclusion %}{% inclusion_only_unlimited_args_from_template 37 42 56 89 %}", - "inclusion_only_unlimited_args_from_template - Expected result: 37, 42, 56, 89\n", + "{% load inclusion %}" + "{% inclusion_only_unlimited_args_from_template 37 42 56 89 %}", + "inclusion_only_unlimited_args_from_template - Expected result: 37, " + "42, 56, 89\n", ), ] diff --git a/tests/template_tests/test_extends.py b/tests/template_tests/test_extends.py index bce5162d83..ce1838654b 100644 --- a/tests/template_tests/test_extends.py +++ b/tests/template_tests/test_extends.py @@ -45,13 +45,16 @@ class ExtendsBehaviorTests(SimpleTestCase): "django.template.loaders.locmem.Loader", { "one.html": ( - '{% extends "one.html" %}{% block content %}{{ block.super }} locmem-one{% endblock %}' + '{% extends "one.html" %}{% block content %}' + "{{ block.super }} locmem-one{% endblock %}" ), "two.html": ( - '{% extends "two.html" %}{% block content %}{{ block.super }} locmem-two{% endblock %}' + '{% extends "two.html" %}{% block content %}' + "{{ block.super }} locmem-two{% endblock %}" ), "three.html": ( - '{% extends "three.html" %}{% block content %}{{ block.super }} locmem-three{% endblock %}' + '{% extends "three.html" %}{% block content %}' + "{{ block.super }} locmem-three{% endblock %}" ), }, ), @@ -126,7 +129,10 @@ class ExtendsBehaviorTests(SimpleTestCase): [ "django.template.loaders.locmem.Loader", { - "base.html": '{% extends "base.html" %}{% block content %}{{ block.super }} loader1{% endblock %}', + "base.html": ( + '{% extends "base.html" %}{% block content %}' + "{{ block.super }} loader1{% endblock %}" + ), }, ], [ @@ -151,14 +157,23 @@ class ExtendsBehaviorTests(SimpleTestCase): [ "django.template.loaders.locmem.Loader", { - "base.html": "{% extends 'base.html' %}{% block base %}{{ block.super }}2{% endblock %}", - "included.html": "{% extends 'included.html' %}{% block included %}{{ block.super }}B{% endblock %}", + "base.html": ( + "{% extends 'base.html' %}{% block base %}{{ block.super }}" + "2{% endblock %}" + ), + "included.html": ( + "{% extends 'included.html' %}{% block included %}" + "{{ block.super }}B{% endblock %}" + ), }, ], [ "django.template.loaders.locmem.Loader", { - "base.html": "{% block base %}1{% endblock %}{% include 'included.html' %}", + "base.html": ( + "{% block base %}1{% endblock %}" + "{% include 'included.html' %}" + ), "included.html": "{% block included %}A{% endblock %}", }, ], diff --git a/tests/template_tests/test_parser.py b/tests/template_tests/test_parser.py index ee9b9b1b12..e40a5611e2 100644 --- a/tests/template_tests/test_parser.py +++ b/tests/template_tests/test_parser.py @@ -1,5 +1,6 @@ """ -Testing some internals of the template processing. These are *not* examples to be copied in user code. +Testing some internals of the template processing. +These are *not* examples to be copied in user code. """ from django.template import Library, TemplateSyntaxError from django.template.base import ( |
