summaryrefslogtreecommitdiff
path: root/tests/template_tests/test_engine.py
diff options
context:
space:
mode:
authorabhiabhi94 <13880786+abhiabhi94@users.noreply.github.com>2021-05-28 06:15:40 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-06-01 07:44:36 +0200
commitc609d5149c9295207cd7b2e8154e7b80a18d834a (patch)
tree95f6622ee891044e332dea0c2012c1c4fa0eedc4 /tests/template_tests/test_engine.py
parent55775891fbfd8679b75336aa2f15ff9190e9f7a8 (diff)
Refs #24121 -- Added __repr__() to Engine
Diffstat (limited to 'tests/template_tests/test_engine.py')
-rw-r--r--tests/template_tests/test_engine.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/template_tests/test_engine.py b/tests/template_tests/test_engine.py
index b975ea87b4..2b32211761 100644
--- a/tests/template_tests/test_engine.py
+++ b/tests/template_tests/test_engine.py
@@ -10,6 +10,43 @@ 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),
+ "<Engine: app_dirs=False debug=False loaders=[("
+ "'django.template.loaders.cached.Loader', "
+ "['django.template.loaders.filesystem.Loader'])] "
+ "string_if_invalid='' file_charset='utf-8' builtins=["
+ "'django.template.defaulttags', 'django.template.defaultfilters', "
+ "'django.template.loader_tags'] autoescape=True>"
+ )
+
+ 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"<Engine: dirs=[{TEMPLATE_DIR!r}] app_dirs=False "
+ "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'} "
+ "builtins=['django.template.defaulttags', "
+ "'django.template.defaultfilters', 'django.template.loader_tags'] "
+ "autoescape=False>"
+ )
+
+
class RenderToStringTest(SimpleTestCase):
def setUp(self):