From d7bc37d611b43d58be4b430faf0b9813bcde29c6 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 9 Jan 2015 22:18:34 +0100 Subject: Fixed #24097 -- Prevented AttributeError in redirect_to_login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks Peter Schmidt for the report and the initial patch. Thanks to ​Oktay Sancak for writing the original failing test and Alvin Savoy for supporting contributing back to the community. --- tests/resolve_url/tests.py | 12 +++++++++++- tests/resolve_url/urls.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/resolve_url/tests.py b/tests/resolve_url/tests.py index ce550ea846..0fc3307026 100644 --- a/tests/resolve_url/tests.py +++ b/tests/resolve_url/tests.py @@ -1,10 +1,11 @@ from __future__ import unicode_literals -from django.core.urlresolvers import NoReverseMatch +from django.core.urlresolvers import NoReverseMatch, reverse_lazy from django.contrib.auth.views import logout from django.shortcuts import resolve_url from django.test import TestCase, ignore_warnings, override_settings from django.utils.deprecation import RemovedInDjango20Warning +from django.utils import six from .models import UnimportantThing @@ -56,6 +57,15 @@ class ResolveUrlTests(TestCase): resolved_url = resolve_url(logout) self.assertEqual('/accounts/logout/', resolved_url) + def test_lazy_reverse(self): + """ + Tests that passing the result of reverse_lazy is resolved to a real URL + string. + """ + resolved_url = resolve_url(reverse_lazy('logout')) + self.assertIsInstance(resolved_url, six.text_type) + self.assertEqual('/accounts/logout/', resolved_url) + @ignore_warnings(category=RemovedInDjango20Warning) def test_valid_view_name(self): """ diff --git a/tests/resolve_url/urls.py b/tests/resolve_url/urls.py index eb3720a503..e78b833927 100644 --- a/tests/resolve_url/urls.py +++ b/tests/resolve_url/urls.py @@ -2,5 +2,5 @@ from django.conf.urls import url from django.contrib.auth import views urlpatterns = [ - url(r'^accounts/logout/$', views.logout), + url(r'^accounts/logout/$', views.logout, name='logout'), ] -- cgit v1.3