#35522: 'NoneType' object has no attribute 'lstrip' when loading single template
with relative include without origin
-------------------------------------------+------------------------
               Reporter:  Hovi             |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Template system  |        Version:  5.0
               Severity:  Normal           |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 Behaviour described by this test:


 {{{

 from django.template import Template, Origin, TemplateSyntaxError
 from django.test import TestCase


 class TestInclude(TestCase):
     def test_passes(self):
         Template(
             """
 {% include "question.html" %}
         """
         )

     def test_also_passes(self):
         Template(
             """
 {% include "./question.html" %}
         """,
             origin=Origin(
                 name="doesntmatter.html", template_name="need-to-be-
 set.html"
             ),
         )

     def test_fails_correctly(self):
         with self.assertRaises(TemplateSyntaxError) as cm:
             Template(
                 """
     {% include "../question.html" %}
             """,
                 origin=Origin(
                     name="doesntmatter.html", template_name="need-to-be-
 set.html"
                 ),
             )
             self.assertIn("points outside the file hierarchy that
 template", str(cm.exception))

     def test_fails(self):
         with self.assertRaises(AttributeError) as cm:
             Template(
                 """
         {% include "./question.html" %}
             """
             )
             self.assertIn("'NoneType' object has no attribute 'lstrip'",
 str(cm.exception))

     def test_fails_on_incorrect_error(self):
         with self.assertRaises(AttributeError) as cm:
             Template(
                 """
         {% include "../question.html" %}
             """
             )
             self.assertIn("'NoneType' object has no attribute 'lstrip'",
 str(cm.exception))
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35522>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701900c2b9ea1-801b1be3-f18a-4009-bedd-6040e06b8961-000000%40eu-central-1.amazonses.com.

Reply via email to