mirror of https://github.com/django/django.git
[1.6.x] Tweaked strip_tags tests to pass on Python 3.3
Backport of 6a0291bda
from master.
This commit is contained in:
parent
f05f5c231a
commit
c9b2feffee
|
@ -63,7 +63,6 @@ class TestUtilsHtml(TestCase):
|
||||||
self.check_output(f, value, output)
|
self.check_output(f, value, output)
|
||||||
|
|
||||||
def test_strip_tags(self):
|
def test_strip_tags(self):
|
||||||
from django.utils.html_parser import use_workaround
|
|
||||||
f = html.strip_tags
|
f = html.strip_tags
|
||||||
items = (
|
items = (
|
||||||
('<p>See: 'é is an apostrophe followed by e acute</p>',
|
('<p>See: 'é is an apostrophe followed by e acute</p>',
|
||||||
|
@ -81,13 +80,18 @@ class TestUtilsHtml(TestCase):
|
||||||
('a<p a >b</p>c', 'abc'),
|
('a<p a >b</p>c', 'abc'),
|
||||||
('d<a:b c:d>e</p>f', 'def'),
|
('d<a:b c:d>e</p>f', 'def'),
|
||||||
('<strong>foo</strong><a href="http://example.com">bar</a>', 'foobar'),
|
('<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:
|
for value, output in items:
|
||||||
self.check_output(f, value, output)
|
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)
|
# Test with more lengthy content (also catching performance regressions)
|
||||||
for filename in ('strip_tags1.html', 'strip_tags2.txt'):
|
for filename in ('strip_tags1.html', 'strip_tags2.txt'):
|
||||||
path = os.path.join(os.path.dirname(upath(__file__)), 'files', filename)
|
path = os.path.join(os.path.dirname(upath(__file__)), 'files', filename)
|
||||||
|
|
Loading…
Reference in New Issue