django/tests/template_tests/test_base.py
Dražen Odobašić 253f1b74da [2.0.x] Fixed #29617 -- Fixed Template crash if template_string is lazy.
Regression in 3a148f958dddd97c1379081118c30fbede6b6bc4.
Backport of 9f3b9ffd51c71d96728df9ee16f5a57c6f3b315d from master.
2018-07-31 10:11:18 -04:00

16 lines
611 B
Python

from django.template import Context, Template, VariableDoesNotExist
from django.test import SimpleTestCase
from django.utils.translation import gettext_lazy
class TemplateTests(SimpleTestCase):
def test_lazy_template_string(self):
template_string = gettext_lazy('lazy string')
self.assertEqual(Template(template_string).render(Context()), template_string)
class VariableDoesNotExistTests(SimpleTestCase):
def test_str(self):
exc = VariableDoesNotExist(msg='Failed lookup in %r', params=({'foo': 'bar'},))
self.assertEqual(str(exc), "Failed lookup in {'foo': 'bar'}")