diff options
| author | YogyaChugh <yogyachugh.coder@gmail.com> | 2025-03-22 18:13:26 +0530 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-03-24 17:05:58 +0100 |
| commit | 7164f080474ef0213d1d6e625db647c45c36a5fb (patch) | |
| tree | 3c76acd87cd7573d6931147c4385bff2bcd3436f /tests/template_tests/syntax_tests | |
| parent | 0b4f2d8d397dacb555b327435d1c815da59feda5 (diff) | |
Fixed #36271 -- Raised TemplateSyntaxError when using a relative template path with an unknown origin.
Diffstat (limited to 'tests/template_tests/syntax_tests')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_exceptions.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/template_tests/syntax_tests/test_exceptions.py b/tests/template_tests/syntax_tests/test_exceptions.py index b6d86ac42b..57c4fdb5e6 100644 --- a/tests/template_tests/syntax_tests/test_exceptions.py +++ b/tests/template_tests/syntax_tests/test_exceptions.py @@ -1,4 +1,4 @@ -from django.template import TemplateDoesNotExist, TemplateSyntaxError +from django.template import Template, TemplateDoesNotExist, TemplateSyntaxError from django.test import SimpleTestCase from ..utils import setup @@ -64,3 +64,14 @@ class ExceptionsTests(SimpleTestCase): """ with self.assertRaises(TemplateSyntaxError): self.engine.render_to_string("exception05") + + def test_unknown_origin_relative_path(self): + files = ["./nonexistent.html", "../nonexistent.html"] + for template_name in files: + with self.subTest(template_name=template_name): + msg = ( + f"The relative path '{template_name}' cannot be evaluated due to " + "an unknown template origin." + ) + with self.assertRaisesMessage(TemplateSyntaxError, msg): + Template(f"{{% extends '{template_name}' %}}") |
