Fixed #24055 -- Keep reference to view class for resolve()

This commit is contained in:
Collin Anderson 2014-12-27 02:16:53 -05:00 committed by Loic Bistuer
parent 67235fd4ef
commit a420f83e7d
9 changed files with 42 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import unittest
import warnings
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import resolve
from django.http import HttpResponse
from django.utils import six
from django.utils.deprecation import RemovedInDjango19Warning
@ -329,6 +330,15 @@ class TemplateViewTest(TestCase):
response = self.client.get('/template/content_type/')
self.assertEqual(response['Content-Type'], 'text/plain')
def test_resolve_view(self):
match = resolve('/template/content_type/')
self.assertIs(match.func.view_class, TemplateView)
self.assertEqual(match.func.view_initkwargs['content_type'], 'text/plain')
def test_resolve_login_required_view(self):
match = resolve('/template/login_required/')
self.assertIs(match.func.view_class, TemplateView)
@ignore_warnings(category=RemovedInDjango19Warning)
@override_settings(ROOT_URLCONF='generic_views.urls')