summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorMorgan Aubert <morgan.aubert@impakfinance.com>2018-04-27 17:18:15 -0400
committerTim Graham <timograham@gmail.com>2018-05-09 11:40:28 -0400
commit704443acacf0dfbcb1c52df4b260585055754ce7 (patch)
tree600147bf6114d7b490fcd253ff9797b7e7531c09 /tests/staticfiles_tests
parent7ba040de7703fd06b9b35ddd31da40103d911c30 (diff)
Fixed #29363 -- Added SimpleTestCase.assertWarnsMessage().
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/test_templatetag_deprecation.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/tests/staticfiles_tests/test_templatetag_deprecation.py b/tests/staticfiles_tests/test_templatetag_deprecation.py
index 0194b0745e..898ee68093 100644
--- a/tests/staticfiles_tests/test_templatetag_deprecation.py
+++ b/tests/staticfiles_tests/test_templatetag_deprecation.py
@@ -1,4 +1,3 @@
-import warnings
from urllib.parse import urljoin
from django.contrib.staticfiles import storage
@@ -22,24 +21,16 @@ class StaticDeprecationTests(SimpleTestCase):
def test_templatetag_deprecated(self):
msg = '{% load staticfiles %} is deprecated in favor of {% load static %}.'
template = "{% load staticfiles %}{% static 'main.js' %}"
- with warnings.catch_warnings(record=True) as recorded:
- warnings.simplefilter('always')
+ with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
template = Template(template)
rendered = template.render(Context())
self.assertEqual(rendered, 'https://example.com/assets/main.js')
- self.assertEqual(len(recorded), 1)
- self.assertIs(recorded[0].category, RemovedInDjango30Warning)
- self.assertEqual(str(recorded[0].message), msg)
def test_static_deprecated(self):
msg = (
'django.contrib.staticfiles.templatetags.static() is deprecated in '
'favor of django.templatetags.static.static().'
)
- with warnings.catch_warnings(record=True) as recorded:
- warnings.simplefilter('always')
+ with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
url = static('main.js')
self.assertEqual(url, 'https://example.com/assets/main.js')
- self.assertEqual(len(recorded), 1)
- self.assertIs(recorded[0].category, RemovedInDjango30Warning)
- self.assertEqual(str(recorded[0].message), msg)