1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

[1.7.x] Fixed #24097 -- Prevented AttributeError in redirect_to_login

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.
Backport of d7bc37d61 from master.
This commit is contained in:
Claude Paroz
2015-01-09 22:18:34 +01:00
parent bbcbacf0ad
commit 7e65876b7c
6 changed files with 50 additions and 9 deletions

View File

@@ -1,9 +1,10 @@
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
from django.utils import six
from .models import UnimportantThing
@@ -55,6 +56,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)
def test_valid_view_name(self):
"""
Tests that passing a view function to ``resolve_url`` will result in