Ticket #21351: memoize_problem_21351.diff

File memoize_problem_21351.diff, 1.7 KB (added by bouke, 21 months ago)

memoize num_args implication for get_callable

  • tests/urlpatterns_reverse/tests.py

    diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
    index b2a6d83..48a48a9 100644
    a b from django.contrib.auth.models import User 
    99from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
    1010from django.core.urlresolvers import (reverse, reverse_lazy, resolve, get_callable,
    1111    get_resolver, NoReverseMatch, Resolver404, ResolverMatch, RegexURLResolver,
    12     RegexURLPattern)
     12    RegexURLPattern, _callable_cache)
    1313from django.http import HttpRequest, HttpResponseRedirect, HttpResponsePermanentRedirect
    1414from django.shortcuts import redirect
    1515from django.test import TestCase
    class ErroneousViewTests(TestCase): 
    662662
    663663class ViewLoadingTests(TestCase):
    664664    def test_view_loading(self):
     665        _callable_cache.clear()
     666       
    665667        # A missing view (identified by an AttributeError) should raise
    666668        # ViewDoesNotExist, ...
    667669        six.assertRaisesRegex(self, ViewDoesNotExist, ".*View does not exist in.*",
    class ViewLoadingTests(TestCase): 
    671673        # swallow it.
    672674        self.assertRaises(AttributeError, get_callable,
    673675            'urlpatterns_reverse.views_broken.i_am_broken')
     676
     677    def test_can_fail_memorizing(self):
     678        _callable_cache.clear()
     679
     680        # Swallowing an exception is fine...
     681        get_callable('urlpatterns_reverse.views.i_should_not_exist', True)
     682
     683        ## ... but it should not affect non-swallowing calls.
     684        six.assertRaisesRegex(self, ViewDoesNotExist,
     685                              ".*View does not exist in.*",
     686                              get_callable,
     687                              'urlpatterns_reverse.views.i_should_not_exist')
Back to Top