Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #1178 from bmispelon/master

Fix for test failure introduced by 980ae2a.
  • Loading branch information...
commit a4ab0e8b8648cd4d2dd58396aaccf2be4c23dd85 2 parents c0719d0 + 3cb1e9b
Russell Keith-Magee authored May 19, 2013

Showing 1 changed file with 9 additions and 4 deletions. Show diff stats Hide diff stats

  1. 13  django/contrib/auth/tests/test_views.py
13  django/contrib/auth/tests/test_views.py
@@ -58,15 +58,20 @@ def assertFormError(self, response, error):
58 58
         form_errors = list(itertools.chain(*response.context['form'].errors.values()))
59 59
         self.assertIn(force_text(error), form_errors)
60 60
 
61  
-    def assertURLEqual(self, url, expected):
  61
+    def assertURLEqual(self, url, expected, parse_qs=False):
62 62
         """
63 63
         Given two URLs, make sure all their components (the ones given by
64 64
         urlparse) are equal, only comparing components that are present in both
65 65
         URLs.
  66
+        If `parse_qs` is True, then the querystrings are parsed with QueryDict.
  67
+        This is useful if you don't want the order of parameters to matter.
  68
+        Otherwise, the query strings are compared as-is.
66 69
         """
67 70
         fields = ParseResult._fields
68 71
 
69 72
         for attr, x, y in zip(fields, urlparse(url), urlparse(expected)):
  73
+            if parse_qs and attr == 'query':
  74
+                x, y = QueryDict(x), QueryDict(y)
70 75
             if x and y and x != y:
71 76
                 self.fail("%r != %r (%s doesn't match)" % (url, expected, attr))
72 77
 
@@ -459,10 +464,10 @@ def test_login_form_contains_request(self):
459 464
 @skipIfCustomUser
460 465
 class LoginURLSettings(AuthViewsTestCase):
461 466
     """Tests for settings.LOGIN_URL."""
462  
-    def assertLoginURLEquals(self, url):
  467
+    def assertLoginURLEquals(self, url, parse_qs=False):
463 468
         response = self.client.get('/login_required/')
464 469
         self.assertEqual(response.status_code, 302)
465  
-        self.assertURLEqual(response.url, url)
  470
+        self.assertURLEqual(response.url, url, parse_qs=parse_qs)
466 471
 
467 472
     @override_settings(LOGIN_URL='/login/')
468 473
     def test_standard_login_url(self):
@@ -486,7 +491,7 @@ def test_https_login_url(self):
486 491
 
487 492
     @override_settings(LOGIN_URL='/login/?pretty=1')
488 493
     def test_login_url_with_querystring(self):
489  
-        self.assertLoginURLEquals('/login/?pretty=1&next=/login_required/')
  494
+        self.assertLoginURLEquals('/login/?pretty=1&next=/login_required/', parse_qs=True)
490 495
 
491 496
     @override_settings(LOGIN_URL='http://remote.example.com/login/?next=/default/')
492 497
     def test_remote_login_url_with_next_querystring(self):

0 notes on commit a4ab0e8

Please sign in to comment.
Something went wrong with that request. Please try again.