From 9c19aff7c7561e3a82978a272ecdaad40dda5c00 Mon Sep 17 00:00:00 2001 From: django-bot Date: Thu, 3 Feb 2022 20:24:19 +0100 Subject: Refs #33476 -- Reformatted code with Black. --- tests/template_tests/syntax_tests/test_static.py | 95 ++++++++++++++++-------- 1 file changed, 62 insertions(+), 33 deletions(-) (limited to 'tests/template_tests/syntax_tests/test_static.py') diff --git a/tests/template_tests/syntax_tests/test_static.py b/tests/template_tests/syntax_tests/test_static.py index 6f27d555bf..cd63350cb5 100644 --- a/tests/template_tests/syntax_tests/test_static.py +++ b/tests/template_tests/syntax_tests/test_static.py @@ -8,78 +8,107 @@ from django.test import SimpleTestCase, override_settings from ..utils import setup -@override_settings(INSTALLED_APPS=[], MEDIA_URL='media/', STATIC_URL='static/') +@override_settings(INSTALLED_APPS=[], MEDIA_URL="media/", STATIC_URL="static/") class StaticTagTests(SimpleTestCase): - libraries = {'static': 'django.templatetags.static'} + libraries = {"static": "django.templatetags.static"} - @setup({'static-prefixtag01': '{% load static %}{% get_static_prefix %}'}) + @setup({"static-prefixtag01": "{% load static %}{% get_static_prefix %}"}) def test_static_prefixtag01(self): - output = self.engine.render_to_string('static-prefixtag01') + output = self.engine.render_to_string("static-prefixtag01") self.assertEqual(output, settings.STATIC_URL) - @setup({'static-prefixtag02': '{% load static %}' - '{% get_static_prefix as static_prefix %}{{ static_prefix }}'}) + @setup( + { + "static-prefixtag02": "{% load static %}" + "{% get_static_prefix as static_prefix %}{{ static_prefix }}" + } + ) def test_static_prefixtag02(self): - output = self.engine.render_to_string('static-prefixtag02') + output = self.engine.render_to_string("static-prefixtag02") self.assertEqual(output, settings.STATIC_URL) - @setup({'static-prefixtag03': '{% load static %}{% get_media_prefix %}'}) + @setup({"static-prefixtag03": "{% load static %}{% get_media_prefix %}"}) def test_static_prefixtag03(self): - output = self.engine.render_to_string('static-prefixtag03') + output = self.engine.render_to_string("static-prefixtag03") self.assertEqual(output, settings.MEDIA_URL) - @setup({'static-prefixtag04': '{% load static %}' - '{% get_media_prefix as media_prefix %}{{ media_prefix }}'}) + @setup( + { + "static-prefixtag04": "{% load static %}" + "{% get_media_prefix as media_prefix %}{{ media_prefix }}" + } + ) def test_static_prefixtag04(self): - output = self.engine.render_to_string('static-prefixtag04') + output = self.engine.render_to_string("static-prefixtag04") self.assertEqual(output, settings.MEDIA_URL) - @setup({'t': '{% load static %}{% get_media_prefix ad media_prefix %}{{ media_prefix }}'}) + @setup( + { + "t": "{% load static %}{% get_media_prefix ad media_prefix %}{{ media_prefix }}" + } + ) def test_static_prefixtag_without_as(self): msg = "First argument in 'get_media_prefix' must be 'as'" with self.assertRaisesMessage(TemplateSyntaxError, msg): - self.engine.render_to_string('t') + self.engine.render_to_string("t") - @setup({'static-statictag01': '{% load static %}{% static "admin/base.css" %}'}) + @setup({"static-statictag01": '{% load static %}{% static "admin/base.css" %}'}) def test_static_statictag01(self): - output = self.engine.render_to_string('static-statictag01') - self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css')) + output = self.engine.render_to_string("static-statictag01") + self.assertEqual(output, urljoin(settings.STATIC_URL, "admin/base.css")) - @setup({'static-statictag02': '{% load static %}{% static base_css %}'}) + @setup({"static-statictag02": "{% load static %}{% static base_css %}"}) def test_static_statictag02(self): - output = self.engine.render_to_string('static-statictag02', {'base_css': 'admin/base.css'}) - self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css')) + output = self.engine.render_to_string( + "static-statictag02", {"base_css": "admin/base.css"} + ) + self.assertEqual(output, urljoin(settings.STATIC_URL, "admin/base.css")) - @setup({'static-statictag03': '{% load static %}{% static "admin/base.css" as foo %}{{ foo }}'}) + @setup( + { + "static-statictag03": '{% load static %}{% static "admin/base.css" as foo %}{{ foo }}' + } + ) def test_static_statictag03(self): - output = self.engine.render_to_string('static-statictag03') - self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css')) + output = self.engine.render_to_string("static-statictag03") + self.assertEqual(output, urljoin(settings.STATIC_URL, "admin/base.css")) - @setup({'static-statictag04': '{% load static %}{% static base_css as foo %}{{ foo }}'}) + @setup( + {"static-statictag04": "{% load static %}{% static base_css as foo %}{{ foo }}"} + ) def test_static_statictag04(self): - output = self.engine.render_to_string('static-statictag04', {'base_css': 'admin/base.css'}) - self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css')) + output = self.engine.render_to_string( + "static-statictag04", {"base_css": "admin/base.css"} + ) + self.assertEqual(output, urljoin(settings.STATIC_URL, "admin/base.css")) - @setup({'static-statictag05': '{% load static %}{% static "special?chars"ed.html" %}'}) + @setup( + { + "static-statictag05": '{% load static %}{% static "special?chars"ed.html" %}' + } + ) def test_static_quotes_urls(self): - output = self.engine.render_to_string('static-statictag05') - self.assertEqual(output, urljoin(settings.STATIC_URL, '/static/special%3Fchars%26quoted.html')) + output = self.engine.render_to_string("static-statictag05") + self.assertEqual( + output, + urljoin(settings.STATIC_URL, "/static/special%3Fchars%26quoted.html"), + ) - @setup({'t': '{% load static %}{% static %}'}) + @setup({"t": "{% load static %}{% static %}"}) def test_static_statictag_without_path(self): msg = "'static' takes at least one argument (path to file)" with self.assertRaisesMessage(TemplateSyntaxError, msg): - self.engine.render_to_string('t') + self.engine.render_to_string("t") class StaticNodeTests(SimpleTestCase): def test_repr(self): - static_node = StaticNode(varname='named-var', path='named-path') + static_node = StaticNode(varname="named-var", path="named-path") self.assertEqual( repr(static_node), "StaticNode(varname='named-var', path='named-path')", ) - static_node = StaticNode(path='named-path') + static_node = StaticNode(path="named-path") self.assertEqual( repr(static_node), "StaticNode(varname=None, path='named-path')", -- cgit v1.3