2018-01-21 21:38:52 +00:00
|
|
|
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:
|
2018-04-27 21:18:15 +00:00
|
|
|
with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
|
2018-01-21 21:38:52 +00:00
|
|
|
url = static('path')
|
|
|
|
self.assertEqual(url, '/test/path')
|
|
|
|
finally:
|
|
|
|
staticfiles_storage.base_url = old_url
|