diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2018-03-25 17:32:07 +0430 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-03-26 13:34:23 -0400 |
| commit | 76ae1e9a94cbfddbbf115ad96f26901ba5c02d44 (patch) | |
| tree | 60961d478e034f63291b9f853279935155176130 /tests/template_tests/syntax_tests | |
| parent | 3990d740180bc49a1479b8a2918b0878df65518a (diff) | |
Increased test coverage for {% get_admin_log %} and {% static %}.
Diffstat (limited to 'tests/template_tests/syntax_tests')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_static.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_static.py b/tests/template_tests/syntax_tests/test_static.py index 345f943caf..00f8cdbc11 100644 --- a/tests/template_tests/syntax_tests/test_static.py +++ b/tests/template_tests/syntax_tests/test_static.py @@ -1,6 +1,7 @@ from urllib.parse import urljoin from django.conf import settings +from django.template import TemplateSyntaxError from django.test import SimpleTestCase, override_settings from ..utils import setup @@ -32,6 +33,12 @@ class StaticTagTests(SimpleTestCase): 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 }}'}) + 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') + @setup({'static-statictag01': '{% load static %}{% static "admin/base.css" %}'}) def test_static_statictag01(self): output = self.engine.render_to_string('static-statictag01') @@ -56,3 +63,9 @@ class StaticTagTests(SimpleTestCase): 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')) + + @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') |
