From c70cd2a926ffab47f6613e83e0c8828eb6c2c064 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 26 Apr 2019 20:06:18 +0200 Subject: [PATCH] Refs #15053 -- Clarified debug message when skipping templates to avoid recursion. --- django/template/loaders/base.py | 2 +- tests/template_tests/test_extends.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/django/template/loaders/base.py b/django/template/loaders/base.py index 518f8b457b..b77ea9eca2 100644 --- a/django/template/loaders/base.py +++ b/django/template/loaders/base.py @@ -17,7 +17,7 @@ class Loader: for origin in self.get_template_sources(template_name): if skip is not None and origin in skip: - tried.append((origin, 'Skipped')) + tried.append((origin, 'Skipped to avoid recursion')) continue try: diff --git a/tests/template_tests/test_extends.py b/tests/template_tests/test_extends.py index 0950340f52..38c7ce230f 100644 --- a/tests/template_tests/test_extends.py +++ b/tests/template_tests/test_extends.py @@ -64,8 +64,13 @@ class ExtendsBehaviorTests(SimpleTestCase): """ engine = Engine(dirs=[os.path.join(RECURSIVE, 'fs')]) template = engine.get_template('self.html') - with self.assertRaises(TemplateDoesNotExist): + with self.assertRaises(TemplateDoesNotExist) as e: template.render(Context({})) + tried = e.exception.tried + self.assertEqual(len(tried), 1) + origin, message = tried[0] + self.assertEqual(origin.template_name, 'self.html') + self.assertEqual(message, 'Skipped to avoid recursion') def test_extend_cached(self): engine = Engine(