Ticket #18169: #181692-NoReverseMatch-silenced.patch

File #181692-NoReverseMatch-silenced.patch, 3.1 KB (added by regebro, 9 years ago)

Just a very minor change

  • django/template/base.py

    diff --git a/django/template/base.py b/django/template/base.py
    index f43194d..c23685c 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): 
    788789                            # GOTCHA: This will also catch any TypeError
    789790                            # raised in the function itself.
    790791                            current = settings.TEMPLATE_STRING_IF_INVALID  # invalid method call
     792        except NoReverseMatch:
     793            raise
    791794        except Exception as e:
    792795            if getattr(e, 'silent_variable_failure', False):
    793796                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 c4da50a..51a5692 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): 
    222223        response = self._response('{{ foo }}{{ processors }}').render()
    223224        self.assertEqual(response.content, b'yes')
    224225
     226    def test_included_error_template(self):
     227        """
     228        Test behavior of the raise errors into included blocks.
     229        See #18169
     230        """
     231        load_name = 'included_content.html'
     232        tmpl = TemplateResponse(self.factory.get('/'), load_name, {})
     233        self.assertRaises(NoReverseMatch, tmpl.render)
     234
    225235    def test_render_with_requestcontext(self):
    226236        response = self._response('{{ foo }}{{ processors }}',
    227237                                  {'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