mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #26428 -- Added support for relative path redirects in assertRedirects().
Thanks Trac alias master for the report and review.
This commit is contained in:
@@ -41,7 +41,7 @@ from django.utils.decorators import classproperty
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.six.moves.urllib.parse import (
|
||||
unquote, urlparse, urlsplit, urlunsplit,
|
||||
unquote, urljoin, urlparse, urlsplit, urlunsplit,
|
||||
)
|
||||
from django.utils.six.moves.urllib.request import url2pathname
|
||||
from django.views.static import serve
|
||||
@@ -291,6 +291,11 @@ class SimpleTestCase(unittest.TestCase):
|
||||
url = response.url
|
||||
scheme, netloc, path, query, fragment = urlsplit(url)
|
||||
|
||||
# Prepend the request path to handle relative path redirects.
|
||||
if not path.startswith('/'):
|
||||
url = urljoin(response.request['PATH_INFO'], url)
|
||||
path = urljoin(response.request['PATH_INFO'], path)
|
||||
|
||||
if fetch_redirect_response:
|
||||
redirect_response = response.client.get(path, QueryDict(query),
|
||||
secure=(scheme == 'https'))
|
||||
|
||||
Reference in New Issue
Block a user