|
@@ -246,6 +246,8 @@ class SimpleTestCase(unittest.TestCase):
|
|
|
if msg_prefix:
|
|
|
msg_prefix += ": "
|
|
|
|
|
|
+ e_scheme, e_netloc, e_path, e_query, e_fragment = urlsplit(expected_url)
|
|
|
+
|
|
|
if hasattr(response, 'redirect_chain'):
|
|
|
# The request was a followed redirect
|
|
|
self.assertTrue(len(response.redirect_chain) > 0,
|
|
@@ -259,6 +261,7 @@ class SimpleTestCase(unittest.TestCase):
|
|
|
(response.redirect_chain[0][1], status_code))
|
|
|
|
|
|
url, status_code = response.redirect_chain[-1]
|
|
|
+ scheme, netloc, path, query, fragment = urlsplit(url)
|
|
|
|
|
|
self.assertEqual(response.status_code, target_status_code,
|
|
|
msg_prefix + "Response didn't redirect as expected: Final"
|
|
@@ -276,7 +279,8 @@ class SimpleTestCase(unittest.TestCase):
|
|
|
scheme, netloc, path, query, fragment = urlsplit(url)
|
|
|
|
|
|
if fetch_redirect_response:
|
|
|
- redirect_response = response.client.get(path, QueryDict(query))
|
|
|
+ redirect_response = response.client.get(path, QueryDict(query),
|
|
|
+ secure=(scheme == 'https'))
|
|
|
|
|
|
# Get the redirection page, using the same client that was used
|
|
|
# to obtain the original response.
|
|
@@ -285,10 +289,10 @@ class SimpleTestCase(unittest.TestCase):
|
|
|
" response code was %d (expected %d)" %
|
|
|
(path, redirect_response.status_code, target_status_code))
|
|
|
|
|
|
- e_scheme, e_netloc, e_path, e_query, e_fragment = urlsplit(expected_url)
|
|
|
- if not (e_scheme or e_netloc):
|
|
|
- expected_url = urlunsplit(('http', host or 'testserver', e_path,
|
|
|
- e_query, e_fragment))
|
|
|
+ e_scheme = e_scheme if e_scheme else scheme or 'http'
|
|
|
+ e_netloc = e_netloc if e_netloc else host or 'testserver'
|
|
|
+ expected_url = urlunsplit((e_scheme, e_netloc, e_path, e_query,
|
|
|
+ e_fragment))
|
|
|
|
|
|
self.assertEqual(url, expected_url,
|
|
|
msg_prefix + "Response redirected to '%s', expected '%s'" %
|