summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-03-22 14:41:45 +0100
committerClaude Paroz <claude@2xlibre.net>2014-03-22 15:05:28 +0100
commitc9b2feffeed46765ed6c4b74066059e2a6541735 (patch)
tree3c1fac3f212f359f18ad93ed4e7da617a913bd58
parentf05f5c231a916082b5fa2e0980fbf7abeb390032 (diff)
[1.6.x] Tweaked strip_tags tests to pass on Python 3.3
Backport of 6a0291bda from master.
-rw-r--r--tests/utils_tests/test_html.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index 4774bea684..9c1f22f01f 100644
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -63,7 +63,6 @@ class TestUtilsHtml(TestCase):
self.check_output(f, value, output)
def test_strip_tags(self):
- from django.utils.html_parser import use_workaround
f = html.strip_tags
items = (
('<p>See: &#39;&eacute; is an apostrophe followed by e acute</p>',
@@ -81,13 +80,18 @@ class TestUtilsHtml(TestCase):
('a<p a >b</p>c', 'abc'),
('d<a:b c:d>e</p>f', 'def'),
('<strong>foo</strong><a href="http://example.com">bar</a>', 'foobar'),
- ('<script>alert()</script>&h', 'alert()&h'),
)
- if not use_workaround:
- items += (('<sc<!-- -->ript>test<<!-- -->/script>', 'test'),)
for value, output in items:
self.check_output(f, value, output)
+ # Some convoluted syntax for which parsing may differ between python versions
+ output = html.strip_tags('<sc<!-- -->ript>test<<!-- -->/script>')
+ self.assertNotIn('<script>', output)
+ self.assertIn('test', output)
+ output = html.strip_tags('<script>alert()</script>&h')
+ self.assertNotIn('<script>', output)
+ self.assertIn('alert()', output)
+
# Test with more lengthy content (also catching performance regressions)
for filename in ('strip_tags1.html', 'strip_tags2.txt'):
path = os.path.join(os.path.dirname(upath(__file__)), 'files', filename)