diff options
| author | Tim Graham <timograham@gmail.com> | 2014-06-30 17:48:14 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-06-30 17:53:54 -0400 |
| commit | 735ece0b89b400b95c5e38ae640a7c3fe860c377 (patch) | |
| tree | 5ea592806886ff07b0c9870a11bac5f9df663112 /docs/topics/testing | |
| parent | 6b00b478d204e84637f87fc601203c306002ca52 (diff) | |
[1.6.x] Fixed #19489 -- Documented host parameter of assertRedirects().
Thanks mrknacky at gmail.com for the report and gajimenezmaggiora
for the draft patch.
Backport of e3c7af18a3 from master
Diffstat (limited to 'docs/topics/testing')
| -rw-r--r-- | docs/topics/testing/tools.txt | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 1f59943ade..3961ce852a 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -1270,16 +1270,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='') +.. method:: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, host=None, msg_prefix='') - 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")``. + .. method:: SimpleTestCase.assertHTMLEqual(html1, html2, msg=None) Asserts that the strings ``html1`` and ``html2`` are equal. The comparison |
