summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_safestring.py
diff options
context:
space:
mode:
authorUnai Zalakain <unai@gisa-elkartea.org>2013-10-15 00:40:52 +0200
committerUnai Zalakain <unai@gisa-elkartea.org>2013-10-15 00:42:42 +0200
commitaf64429b991471b7a441e133b5b7d29070984f24 (patch)
treec425d99ae3e8ee7c4b1d856010c577ae27021b27 /tests/utils_tests/test_safestring.py
parentef22d512b54cbf0b5f76151bc760391d839fbf72 (diff)
Fixed #7261 -- support for __html__ for library interoperability
The idea is that if an object implements __html__ which returns a string this is used as HTML representation (eg: on escaping). If the object is a str or unicode subclass and returns itself the object is a safe string type. This is an updated patch based on jbalogh and ivank patches.
Diffstat (limited to 'tests/utils_tests/test_safestring.py')
-rw-r--r--tests/utils_tests/test_safestring.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py
index 5d4528a9a8..4673b26ac7 100644
--- a/tests/utils_tests/test_safestring.py
+++ b/tests/utils_tests/test_safestring.py
@@ -4,7 +4,7 @@ from django.template import Template, Context
from django.test import TestCase
from django.utils.encoding import force_text, force_bytes
from django.utils.functional import lazy, Promise
-from django.utils.html import escape, conditional_escape
+from django.utils.html import escape
from django.utils.safestring import mark_safe, mark_for_escaping
from django.utils import six
from django.utils import translation
@@ -50,3 +50,7 @@ class SafeStringTest(TestCase):
s = mark_safe(translation.ugettext_lazy("username"))
with translation.override('fr'):
self.assertRenderEqual('{{ s }}', "nom d'utilisateur", s=s)
+
+ def test_html(self):
+ s = '<h1>interop</h1>'
+ self.assertEqual(s, mark_safe(s).__html__())