summaryrefslogtreecommitdiff
path: root/tests/regressiontests/utils/html.py
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2012-06-30 18:54:38 +0100
committerLuke Plant <L.Plant.98@cantab.net>2012-07-03 22:20:12 +0100
commitbee498f3a2f66210db39f0be244ec4fa888b6940 (patch)
tree95252d804377899b9d5bb3bff1a1c8dc6206d835 /tests/regressiontests/utils/html.py
parentf33e15036907d6e4bda6116dc84097e9e590d2c8 (diff)
Added 'format_html' utility for formatting HTML fragments safely
Diffstat (limited to 'tests/regressiontests/utils/html.py')
-rw-r--r--tests/regressiontests/utils/html.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/regressiontests/utils/html.py b/tests/regressiontests/utils/html.py
index 434873b9e0..389ae8ec75 100644
--- a/tests/regressiontests/utils/html.py
+++ b/tests/regressiontests/utils/html.py
@@ -34,6 +34,17 @@ class TestUtilsHtml(unittest.TestCase):
# Verify it doesn't double replace &.
self.check_output(f, '<&', '&lt;&amp;')
+ def test_format_html(self):
+ self.assertEqual(
+ html.format_html(u"{0} {1} {third} {fourth}",
+ u"< Dangerous >",
+ html.mark_safe(u"<b>safe</b>"),
+ third="< dangerous again",
+ fourth=html.mark_safe(u"<i>safe again</i>")
+ ),
+ u"&lt; Dangerous &gt; <b>safe</b> &lt; dangerous again <i>safe again</i>"
+ )
+
def test_linebreaks(self):
f = html.linebreaks
items = (