1
# Copyright 2016 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
from __future__ import unicode_literals
6
from django.template import (
11
from identityprovider.tests.utils import SSOBaseTestCase
12
from webui.utils import mark_safe_lazy
15
class LazyMarkSafeTestCase(SSOBaseTestCase):
17
def render_string_in_template(self, string):
18
"""Render 'string' in a template, return the result."""
19
template = Template('{{ str }}')
20
context = Context(dict(str=string))
21
return template.render(context)
23
def test_returns_safe_string(self):
24
lazy_string = mark_safe_lazy("<b>Lazy</b>")
25
observed = self.render_string_in_template(lazy_string)
26
self.assertEqual("<b>Lazy</b>", observed)