1
0
mirror of https://github.com/django/django.git synced 2025-10-29 16:46:11 +00:00

Refs #21221 -- Deprecated staticfiles and admin_static template tag libraries.

This commit is contained in:
Jon Dufresne
2018-01-21 13:38:52 -08:00
committed by Tim Graham
parent f0f383b635
commit 7d607127e3
9 changed files with 109 additions and 23 deletions

View File

@@ -0,0 +1,30 @@
import warnings
from django.contrib.admin.templatetags.admin_static import static
from django.contrib.staticfiles.storage import staticfiles_storage
from django.test import SimpleTestCase
from django.utils.deprecation import RemovedInDjango30Warning
class AdminStaticDeprecationTests(SimpleTestCase):
def test(self):
"""
admin_static.static points to the collectstatic version
(as django.contrib.collectstatic is in INSTALLED_APPS).
"""
msg = (
'{% load admin_static %} is deprecated in favor of '
'{% load static %}.'
)
old_url = staticfiles_storage.base_url
staticfiles_storage.base_url = '/test/'
try:
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter('always')
url = static('path')
self.assertEqual(url, '/test/path')
self.assertEqual(len(recorded), 1)
self.assertIs(recorded[0].category, RemovedInDjango30Warning)
self.assertEqual(str(recorded[0].message), msg)
finally:
staticfiles_storage.base_url = old_url