import os from django.core.exceptions import ImproperlyConfigured from django.template import Context from django.template.engine import Engine from django.test import SimpleTestCase, override_settings from .utils import ROOT, TEMPLATE_DIR OTHER_DIR = os.path.join(ROOT, 'other_templates') class EngineTest(SimpleTestCase): def test_repr_empty(self): engine = Engine() self.assertEqual( repr(engine), "" ) def test_repr(self): engine = Engine( dirs=[TEMPLATE_DIR], context_processors=['django.template.context_processors.debug'], debug=True, loaders=['django.template.loaders.filesystem.Loader'], string_if_invalid='x', file_charset='utf-16', libraries={'custom': 'template_tests.templatetags.custom'}, autoescape=False, ) self.assertEqual( repr(engine), f"" ) class RenderToStringTest(SimpleTestCase): def setUp(self): self.engine = Engine(dirs=[TEMPLATE_DIR]) def test_basic_context(self): self.assertEqual( self.engine.render_to_string('test_context.html', {'obj': 'test'}), 'obj:test\n', ) def test_autoescape_off(self): engine = Engine(dirs=[TEMPLATE_DIR], autoescape=False) self.assertEqual( engine.render_to_string('test_context.html', {'obj': '