Ticket #18169: 181692.3.patch

File 181692.3.patch, 3.1 KB (added by Roman Gladkov, 9 years ago)
  • django/template/base.py

    diff --git a/django/template/base.py b/django/template/base.py
    index 0a2b2c9..cfa9f38 100644
    a b from inspect import getargspec 
    77from django.conf import settings
    88from django.template.context import (Context, RequestContext,
    99    ContextPopException)
     10from django.core.urlresolvers import NoReverseMatch
    1011from django.utils.importlib import import_module
    1112from django.utils.itercompat import is_iterable
    1213from django.utils.text import (smart_split, unescape_string_literal,
    class Variable(object): 
    781782                            # GOTCHA: This will also catch any TypeError
    782783                            # raised in the function itself.
    783784                            current = settings.TEMPLATE_STRING_IF_INVALID  # invalid method call
     785        except NoReverseMatch, e:
     786            raise e
    784787        except Exception as e:
    785788            if getattr(e, 'silent_variable_failure', False):
    786789                current = settings.TEMPLATE_STRING_IF_INVALID
  • tests/regressiontests/templates/response.py

    diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py
    index 93919b9..737adc9 100644
    a b from datetime import datetime 
    77
    88from django.test import RequestFactory, TestCase
    99from django.conf import settings
     10from django.core.urlresolvers import NoReverseMatch
    1011from django.template import Template, Context
    1112from django.template.response import (TemplateResponse, SimpleTemplateResponse,
    1213                                      ContentNotRenderedError)
    class TemplateResponseTest(TestCase): 
    206207        response = self._response('{{ foo }}{{ processors }}').render()
    207208        self.assertEqual(response.content, b'yes')
    208209
     210    def test_included_error_template(self):
     211        """
     212        Test behavior of the raise errors into included blocks.
     213        See #18169
     214        """
     215        load_name = 'included_content.html'
     216        tmpl = TemplateResponse(self.factory.get('/'), load_name, {})
     217        self.assertRaises(NoReverseMatch, tmpl.render)
     218
    209219    def test_render_with_requestcontext(self):
    210220        response = self._response('{{ foo }}{{ processors }}',
    211221                                  {'foo': 'bar'}).render()
  • new file tests/regressiontests/templates/templates/included_base.html

    diff --git a/tests/regressiontests/templates/templates/included_base.html b/tests/regressiontests/templates/templates/included_base.html
    new file mode 100644
    index 0000000..eae222c
    - +  
     1{% block content %}
     2  {% block error_here %}{% endblock %}
     3{% endblock %}
  • new file tests/regressiontests/templates/templates/included_content.html

    diff --git a/tests/regressiontests/templates/templates/included_content.html b/tests/regressiontests/templates/templates/included_content.html
    new file mode 100644
    index 0000000..4945f72
    - +  
     1{% extends "included_base.html" %}
     2
     3{% block content %}
     4  content
     5  {{ block.super }}
     6{% endblock %}
     7
     8{% block error_here %}
     9  error here
     10  {% url non_existing_url %}
     11{% endblock %}
Back to Top