summaryrefslogtreecommitdiff
path: root/tests/resolve_url
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-01-09 22:18:34 +0100
committerClaude Paroz <claude@2xlibre.net>2015-01-10 10:05:02 +0100
commitd7bc37d611b43d58be4b430faf0b9813bcde29c6 (patch)
tree3cf286e0f09f2fc89dee888688d0c098669a4bb6 /tests/resolve_url
parentf5c3a8bff57add71b801c9c44442ea0f8fa35858 (diff)
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.
Diffstat (limited to 'tests/resolve_url')
-rw-r--r--tests/resolve_url/tests.py12
-rw-r--r--tests/resolve_url/urls.py2
2 files changed, 12 insertions, 2 deletions
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'),
]