Loading tests/template_backends/test_jinja2.py +2 −9 Original line number Diff line number Diff line Loading @@ -24,18 +24,11 @@ class Jinja2Tests(TemplateStringsTests): def test_self_context(self): """ #24538 -- Using 'self' in the context should not throw errors Using 'self' in the context should not throw errors (#24538). """ engine = Jinja2({ 'DIRS': [], 'APP_DIRS': False, 'NAME': 'django', 'OPTIONS': {}, }) # self will be overridden to be a TemplateReference, so the self # variable will not come through. Attempting to use one though should # not throw an error. template = engine.from_string('hello {{ foo }}!') template = self.engine.from_string('hello {{ foo }}!') content = template.render(context={'self': 'self', 'foo': 'world'}) self.assertEqual(content, 'hello world!') Loading
tests/template_backends/test_jinja2.py +2 −9 Original line number Diff line number Diff line Loading @@ -24,18 +24,11 @@ class Jinja2Tests(TemplateStringsTests): def test_self_context(self): """ #24538 -- Using 'self' in the context should not throw errors Using 'self' in the context should not throw errors (#24538). """ engine = Jinja2({ 'DIRS': [], 'APP_DIRS': False, 'NAME': 'django', 'OPTIONS': {}, }) # self will be overridden to be a TemplateReference, so the self # variable will not come through. Attempting to use one though should # not throw an error. template = engine.from_string('hello {{ foo }}!') template = self.engine.from_string('hello {{ foo }}!') content = template.render(context={'self': 'self', 'foo': 'world'}) self.assertEqual(content, 'hello world!')