diff options
| author | Tim Graham <timograham@gmail.com> | 2014-08-11 07:24:51 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-08-15 08:20:02 -0400 |
| commit | e122facbd89c5768528f5ba3b13552d43f989757 (patch) | |
| tree | 84f990612dffbb119a8620e1dccae10f4f76c45f /tests | |
| parent | deed00c0d803d324a3dfdeba52458b6b009c1a90 (diff) | |
Fixed #23269 -- Deprecated django.utils.remove_tags() and removetags filter.
Also the unused, undocumented django.utils.html.strip_entities() function.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/defaultfilters/tests.py | 14 | ||||
| -rw-r--r-- | tests/template_tests/tests.py | 3 | ||||
| -rw-r--r-- | tests/utils_tests/test_html.py | 13 |
3 files changed, 22 insertions, 8 deletions
diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py index c61227efd5..7d135f8caf 100644 --- a/tests/defaultfilters/tests.py +++ b/tests/defaultfilters/tests.py @@ -433,9 +433,13 @@ class DefaultFiltersTests(TestCase): 'line 1<br />line 2') def test_removetags(self): - self.assertEqual(removetags('some <b>html</b> with <script>alert' - '("You smell")</script> disallowed <img /> tags', 'script img'), - 'some <b>html</b> with alert("You smell") disallowed tags') + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + self.assertEqual(removetags('some <b>html</b> with <script>alert' + '("You smell")</script> disallowed <img /> tags', 'script img'), + 'some <b>html</b> with alert("You smell") disallowed tags') + + def test_striptags(self): self.assertEqual(striptags('some <b>html</b> with <script>alert' '("You smell")</script> disallowed <img /> tags'), 'some html with alert("You smell") disallowed tags') @@ -713,7 +717,9 @@ class DefaultFiltersTests(TestCase): self.assertEqual(escape(123), '123') self.assertEqual(linebreaks_filter(123), '<p>123</p>') self.assertEqual(linebreaksbr(123), '123') - self.assertEqual(removetags(123, 'a'), '123') + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + self.assertEqual(removetags(123, 'a'), '123') self.assertEqual(striptags(123), '123') diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index c24040ebfe..ed3a019721 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -590,7 +590,8 @@ class TemplateTests(TestCase): # Ignore deprecations of using the wrong number of variables with the 'for' tag. # and warnings for {% url %} reversing by dotted path warnings.filterwarnings("ignore", category=RemovedInDjango20Warning, module="django.template.defaulttags") - # Ignore deprecations of old style unordered_list. + # Ignore deprecations of old style unordered_list + # and removetags. warnings.filterwarnings("ignore", category=RemovedInDjango20Warning, module="django.template.defaultfilters") output = self.render(test_template, vals) except ShouldNotExecuteException: diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index 0c6167ef50..d08eb0be2b 100644 --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from datetime import datetime import os from unittest import TestCase +import warnings from django.utils import html, safestring from django.utils._os import upath @@ -124,7 +125,9 @@ class TestUtilsHtml(TestCase): # Strings that should come out untouched. values = ("&", "&a", "&a", "a&#a") for value in values: - self.check_output(f, value) + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + self.check_output(f, value) # Valid entities that should be stripped from the patterns. entities = ("", "", "&a;", "&fdasdfasdfasdf;") patterns = ( @@ -135,7 +138,9 @@ class TestUtilsHtml(TestCase): ) for entity in entities: for in_pattern, output in patterns: - self.check_output(f, in_pattern % {'entity': entity}, output) + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + self.check_output(f, in_pattern % {'entity': entity}, output) def test_escapejs(self): f = html.escapejs @@ -156,7 +161,9 @@ class TestUtilsHtml(TestCase): ("<a>x</a> <p><b>y</b></p>", "a b", "x <p>y</p>"), ) for value, tags, output in items: - self.assertEqual(f(value, tags), output) + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + self.assertEqual(f(value, tags), output) def test_smart_urlquote(self): quote = html.smart_urlquote |
