Refs #24121 -- Added __repr__() to Engine

This commit is contained in:
abhiabhi94 2021-05-28 06:15:40 +05:30 committed by Mariusz Felisiak
parent 55775891fb
commit c609d5149c
2 changed files with 57 additions and 0 deletions

View file

@ -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):