diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index 1ceb51ea2b..c0a72c7dc1 100644 --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -32,11 +32,13 @@ class TestUtilsHtml(SimpleTestCase): # Substitution patterns for testing the above items. patterns = ("%s", "asdf%sfdsa", "%s1", "1%sb") for value, output in items: - for pattern in patterns: - self.check_output(escape, pattern % value, pattern % output) - self.check_output(escape, lazystr(pattern % value), pattern % output) - # Check repeated values. - self.check_output(escape, value * 2, output * 2) + with self.subTest(value=value, output=output): + for pattern in patterns: + with self.subTest(value=value, output=output, pattern=pattern): + self.check_output(escape, pattern % value, pattern % output) + self.check_output(escape, lazystr(pattern % value), pattern % output) + # Check repeated values. + self.check_output(escape, value * 2, output * 2) # Verify it doesn't double replace &. self.check_output(escape, '<&', '<&') @@ -60,8 +62,9 @@ class TestUtilsHtml(SimpleTestCase): ("para1\tmore\n\npara2", "

para1\tmore

\n\n

para2

"), ) for value, output in items: - self.check_output(linebreaks, value, output) - self.check_output(linebreaks, lazystr(value), output) + with self.subTest(value=value, output=output): + self.check_output(linebreaks, value, output) + self.check_output(linebreaks, lazystr(value), output) def test_strip_tags(self): items = ( @@ -83,37 +86,36 @@ class TestUtilsHtml(SimpleTestCase): # caused infinite loop on Pythons not patched with # http://bugs.python.org/issue20288 ('&gotcha&#;<>', '&gotcha&#;<>'), + ('ript>test</script>', 'ript>test'), + ('&h', 'alert()h'), ) for value, output in items: - self.check_output(strip_tags, value, output) - self.check_output(strip_tags, lazystr(value), output) - - # Some convoluted syntax for which parsing may differ between python versions - output = strip_tags('ript>test</script>') - self.assertNotIn('&h') - self.assertNotIn('