summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests/test_forms.py
diff options
context:
space:
mode:
authorJohannes Hoppe <info@johanneshoppe.com>2016-01-15 00:16:42 +0700
committerTim Graham <timograham@gmail.com>2016-01-19 06:57:20 -0500
commit20e2b228aa87f2ce6341d5e96642c53b87a87459 (patch)
tree54063221b0e82864e280af4277486a104bce1cf6 /tests/staticfiles_tests/test_forms.py
parent33c73d297f3220204821f64e77cfeaac428aacf1 (diff)
Refs #21221 -- Added test for legacy static usage in form Media.
Before cf546e1, static files in form or widget Media were usually wrapped with contrib.staticfiles.templatetags.staticfiles.static. This test ensures compatibility with third-party code that's still using this pattern.
Diffstat (limited to 'tests/staticfiles_tests/test_forms.py')
-rw-r--r--tests/staticfiles_tests/test_forms.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/staticfiles_tests/test_forms.py b/tests/staticfiles_tests/test_forms.py
index f5bd24186b..e3d4772662 100644
--- a/tests/staticfiles_tests/test_forms.py
+++ b/tests/staticfiles_tests/test_forms.py
@@ -1,4 +1,5 @@
from django.contrib.staticfiles import storage
+from django.contrib.staticfiles.templatetags.staticfiles import static
from django.forms import Media
from django.test import SimpleTestCase, override_settings
from django.utils.six.moves.urllib.parse import urljoin
@@ -18,7 +19,12 @@ class StaticFilesFormsMediaTestCase(SimpleTestCase):
def test_absolute_url(self):
m = Media(
css={'all': ('path/to/css1', '/path/to/css2')},
- js=('/path/to/js1', 'http://media.other.com/path/to/js2', 'https://secure.other.com/path/to/js3'),
+ js=(
+ '/path/to/js1',
+ 'http://media.other.com/path/to/js2',
+ 'https://secure.other.com/path/to/js3',
+ static('relative/path/to/js4'),
+ ),
)
self.assertEqual(
str(m),
@@ -26,5 +32,6 @@ class StaticFilesFormsMediaTestCase(SimpleTestCase):
<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/path/to/js1"></script>
<script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
-<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>"""
+<script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
+<script type="text/javascript" src="https://example.com/assets/relative/path/to/js4"></script>"""
)