mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #23768 -- Rewrote template tests as unit tests.
This commit is contained in:
parent
4a4ad27712
commit
b872134bfc
41 changed files with 4855 additions and 1369 deletions
51
tests/template_tests/syntax_tests/test_static.py
Normal file
51
tests/template_tests/syntax_tests/test_static.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
from django.conf import settings
|
||||
from django.test import override_settings, TestCase
|
||||
from django.utils.six.moves.urllib.parse import urljoin
|
||||
|
||||
from .utils import render, setup
|
||||
|
||||
|
||||
@override_settings(MEDIA_URL="/media/", STATIC_URL="/static/")
|
||||
class StaticTagTests(TestCase):
|
||||
|
||||
@setup({'static-prefixtag01': '{% load static %}{% get_static_prefix %}'})
|
||||
def test_static_prefixtag01(self):
|
||||
output = render('static-prefixtag01')
|
||||
self.assertEqual(output, settings.STATIC_URL)
|
||||
|
||||
@setup({'static-prefixtag02': '{% load static %}'
|
||||
'{% get_static_prefix as static_prefix %}{{ static_prefix }}'})
|
||||
def test_static_prefixtag02(self):
|
||||
output = render('static-prefixtag02')
|
||||
self.assertEqual(output, settings.STATIC_URL)
|
||||
|
||||
@setup({'static-prefixtag03': '{% load static %}{% get_media_prefix %}'})
|
||||
def test_static_prefixtag03(self):
|
||||
output = render('static-prefixtag03')
|
||||
self.assertEqual(output, settings.MEDIA_URL)
|
||||
|
||||
@setup({'static-prefixtag04': '{% load static %}'
|
||||
'{% get_media_prefix as media_prefix %}{{ media_prefix }}'})
|
||||
def test_static_prefixtag04(self):
|
||||
output = render('static-prefixtag04')
|
||||
self.assertEqual(output, settings.MEDIA_URL)
|
||||
|
||||
@setup({'static-statictag01': '{% load static %}{% static "admin/base.css" %}'})
|
||||
def test_static_statictag01(self):
|
||||
output = render('static-statictag01')
|
||||
self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css'))
|
||||
|
||||
@setup({'static-statictag02': '{% load static %}{% static base_css %}'})
|
||||
def test_static_statictag02(self):
|
||||
output = render('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 }}'})
|
||||
def test_static_statictag03(self):
|
||||
output = render('static-statictag03')
|
||||
self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css'))
|
||||
|
||||
@setup({'static-statictag04': '{% load static %}{% static base_css as foo %}{{ foo }}'})
|
||||
def test_static_statictag04(self):
|
||||
output = render('static-statictag04', {'base_css': 'admin/base.css'})
|
||||
self.assertEqual(output, urljoin(settings.STATIC_URL, 'admin/base.css'))
|
Loading…
Add table
Add a link
Reference in a new issue