diff options
| author | Jan Pieter Waagmeester <jieter@jieter.nl> | 2017-12-19 20:05:10 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-06-20 13:26:12 -0400 |
| commit | 24959e48d949a20be969f649ece3576dbc7ce422 (patch) | |
| tree | 0d2e751a91e3af2fdc890e912eaf1a1ee93acb9d /docs | |
| parent | 42490768441701bc02255b22df8e6894cbe487c7 (diff) | |
Fixed #27398 -- Added an assertion to compare URLs, ignoring the order of their query strings.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/2.2.txt | 4 | ||||
| -rw-r--r-- | docs/topics/testing/tools.txt | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/docs/releases/2.2.txt b/docs/releases/2.2.txt index 5994a054a6..a968ffa53c 100644 --- a/docs/releases/2.2.txt +++ b/docs/releases/2.2.txt @@ -183,7 +183,9 @@ Templates Tests ~~~~~ -* ... +* The new :meth:`.SimpleTestCase.assertURLEqual` assertion checks for a given + URL, ignoring the ordering of the query string. + :meth:`~.SimpleTestCase.assertRedirects` uses the new assertion. URLs ~~~~ diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 1f7d3b4f06..6e0cfad80b 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -700,6 +700,7 @@ A subclass of :class:`unittest.TestCase` that adds this functionality: <SimpleTestCase.assertContains>`. * Verifying that a template :meth:`has/hasn't been used to generate a given response content <SimpleTestCase.assertTemplateUsed>`. + * Verifying that two :meth:`URLs <SimpleTestCase.assertURLEqual>` are equal. * Verifying a HTTP :meth:`redirect <SimpleTestCase.assertRedirects>` is performed by the app. * Robustly testing two :meth:`HTML fragments <SimpleTestCase.assertHTMLEqual>` @@ -1477,6 +1478,15 @@ your test suite. You can use this as a context manager in the same way as :meth:`~SimpleTestCase.assertTemplateUsed`. +.. method:: SimpleTestCase.assertURLEqual(url1, url2, msg_prefix='') + + .. versionadded:: 2.2 + + Asserts that two URLs are the same, ignoring the order of query string + parameters except for parameters with the same name. For example, + ``/path/?x=1&y=2`` is equal to ``/path/?y=2&x=1``, but + ``/path/?a=1&a=2`` isn't equal to ``/path/?a=2&a=1``. + .. method:: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, msg_prefix='', fetch_redirect_response=True) Asserts that the response returned a ``status_code`` redirect status, |
