summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-06-30 17:48:14 -0400
committerTim Graham <timograham@gmail.com>2014-06-30 17:52:04 -0400
commite3c7af18a307f9d020eb798bdad6cc63ab22dac9 (patch)
tree02b6ca5fde7ae81be78eec701ef41bbbf2bff443 /docs
parent874053edf92c02e1ab155bdf7491b08f9863dce8 (diff)
Fixed #19489 -- Documented host parameter of assertRedirects().
Thanks mrknacky at gmail.com for the report and gajimenezmaggiora for the draft patch.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/testing/tools.txt16
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index e6433b5235..ecff777263 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -1368,16 +1368,24 @@ your test suite.
You can use this as a context manager in the same way as
:meth:`~SimpleTestCase.assertTemplateUsed`.
-.. method:: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, msg_prefix='', fetch_redirect_response=True)
+.. method:: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, host=None, msg_prefix='', fetch_redirect_response=True)
- Asserts that the response return a ``status_code`` redirect status, it
- redirected to ``expected_url`` (including any GET data), and the final
- page was received with ``target_status_code``.
+ Asserts that the response returned a ``status_code`` redirect status,
+ redirected to ``expected_url`` (including any ``GET`` data), and that the
+ final page was received with ``target_status_code``.
If your request used the ``follow`` argument, the ``expected_url`` and
``target_status_code`` will be the url and status code for the final
point of the redirect chain.
+ The ``host`` argument sets a default host if ``expected_url`` doesn't
+ include one (e.g. ``"/bar/"``). If ``expected_url`` is an absolute URL that
+ includes a host (e.g. ``"http://testhost/bar/"``), the ``host`` parameter
+ will be ignored. Note that the test client doesn't support fetching external
+ URLs, but the parameter may be useful if you are testing with a custom HTTP
+ host (for example, initializing the test client with
+ ``Client(HTTP_HOST="testhost")``.
+
.. versionadded:: 1.7
If ``fetch_redirect_response`` is ``False``, the final page won't be