Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Tweaked strip_tags tests to pass on Python 3.3

Backport of 6a0291b from master.
  • Loading branch information...
commit c9b2feffeed46765ed6c4b74066059e2a6541735 1 parent f05f5c2
@claudep claudep authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 tests/utils_tests/
12 tests/utils_tests/
@@ -63,7 +63,6 @@ def test_linebreaks(self):
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 @@ def test_strip_tags(self):
('a<p a >b</p>c', 'abc'),
('d<a:b c:d>e</p>f', 'def'),
('<strong>foo</strong><a href="">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)
Please sign in to comment.
Something went wrong with that request. Please try again.