MCPcopy
hub / github.com/django/django / test_escape

Method test_escape

tests/utils_tests/test_html.py:40–61  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

38 self.assertEqual(function(value), output)
39
40 def test_escape(self):
41 items = (
42 ("&", "&"),
43 ("<", "&lt;"),
44 (">", "&gt;"),
45 ('"', "&quot;"),
46 ("'", "&#x27;"),
47 )
48 # Substitution patterns for testing the above items.
49 patterns = ("%s", "asdf%sfdsa", "%s1", "1%sb")
50 for value, output in items:
51 with self.subTest(value=value, output=output):
52 for pattern in patterns:
53 with self.subTest(value=value, output=output, pattern=pattern):
54 self.check_output(escape, pattern % value, pattern % output)
55 self.check_output(
56 escape, lazystr(pattern % value), pattern % output
57 )
58 # Check repeated values.
59 self.check_output(escape, value * 2, output * 2)
60 # Verify it doesn't double replace &.
61 self.check_output(escape, "<&", "&lt;&amp;")
62
63 def test_format_html(self):
64 self.assertEqual(

Callers

nothing calls this directly

Calls 2

check_outputMethod · 0.95
lazystrFunction · 0.90

Tested by

no test coverage detected