From f8d52521ab74e538f35c8dcf75760b5a2532c3b5 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 1 Feb 2017 18:56:42 -0500 Subject: [PATCH] Refs #27804 -- Used subTest() in tests.utils_tests.test_html. --- tests/utils_tests/test_html.py | 97 +++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index 1ceb51ea2b0..c0a72c7dc13 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('