From 24959e48d949a20be969f649ece3576dbc7ce422 Mon Sep 17 00:00:00 2001 From: Jan Pieter Waagmeester Date: Tue, 19 Dec 2017 20:05:10 +0100 Subject: Fixed #27398 -- Added an assertion to compare URLs, ignoring the order of their query strings. --- docs/releases/2.2.txt | 4 +++- docs/topics/testing/tools.txt | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'docs') 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: `. * Verifying that a template :meth:`has/hasn't been used to generate a given response content `. + * Verifying that two :meth:`URLs ` are equal. * Verifying a HTTP :meth:`redirect ` is performed by the app. * Robustly testing two :meth:`HTML fragments ` @@ -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, -- cgit v1.3