mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
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.
This commit is contained in:
parent
f5c3a8bff5
commit
d7bc37d611
6 changed files with 48 additions and 8 deletions
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue