mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #20919 -- Extended assertRedirects to be able to avoid fetching redirect's response.
Thanks mjtamlyn for the suggestion.
This commit is contained in:
parent
79ccd1a101
commit
4840fd9cbc
6 changed files with 33 additions and 11 deletions
|
@ -1542,7 +1542,7 @@ 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, 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
|
||||
|
@ -1552,6 +1552,12 @@ your test suite.
|
|||
``target_status_code`` will be the url and status code for the final
|
||||
point of the redirect chain.
|
||||
|
||||
.. versionadded:: 1.7
|
||||
|
||||
If ``fetch_redirect_response`` is ``False``, the final page won't be
|
||||
loaded. Since the test client can't fetch externals URLs, this is
|
||||
particularly useful if ``expected_url`` isn't part of your Django app.
|
||||
|
||||
.. method:: SimpleTestCase.assertHTMLEqual(html1, html2, msg=None)
|
||||
|
||||
Asserts that the strings ``html1`` and ``html2`` are equal. The comparison
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue