Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Modified the requests unit tests so that they aren't dependen…

…t on dictionary ordering.

Backport of r13848 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13949 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit aec5f084a381062c2d98d17583b997beda31447a 1 parent 0f41f91
Russell Keith-Magee authored September 28, 2010

Showing 1 changed file with 22 additions and 24 deletions. Show diff stats Hide diff stats

  1. 46  tests/regressiontests/requests/tests.py
46  tests/regressiontests/requests/tests.py
@@ -10,22 +10,21 @@
10 10
 class RequestsTests(unittest.TestCase):
11 11
 
12 12
     def test_httprequest(self):
13  
-        self.assertEquals(repr(HttpRequest()),
14  
-            "<HttpRequest\n"\
15  
-            "GET:{},\n"\
16  
-            "POST:{},\n"\
17  
-            "COOKIES:{},\n"\
18  
-            "META:{}>"
19  
-        )
  13
+        request = HttpRequest()
  14
+        self.assertEqual(request.GET.keys(), [])
  15
+        self.assertEqual(request.POST.keys(), [])
  16
+        self.assertEqual(request.COOKIES.keys(), [])
  17
+        self.assertEqual(request.META.keys(), [])
20 18
 
21 19
     def test_wsgirequest(self):
22  
-        self.assertEquals(repr(WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 'bogus'})),
23  
-            "<WSGIRequest\n"\
24  
-            "GET:<QueryDict: {}>,\n"\
25  
-            "POST:<QueryDict: {}>,\n"\
26  
-            "COOKIES:{},\n"\
27  
-            "META:{'PATH_INFO': u'bogus', 'REQUEST_METHOD': 'bogus', 'SCRIPT_NAME': u''}>"
28  
-        )
  20
+        request = WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 'bogus'})
  21
+        self.assertEqual(request.GET.keys(), [])
  22
+        self.assertEqual(request.POST.keys(), [])
  23
+        self.assertEqual(request.COOKIES.keys(), [])
  24
+        self.assertEqual(set(request.META.keys()), set(['PATH_INFO', 'REQUEST_METHOD', 'SCRIPT_NAME']))
  25
+        self.assertEqual(request.META['PATH_INFO'], 'bogus')
  26
+        self.assertEqual(request.META['REQUEST_METHOD'], 'bogus')
  27
+        self.assertEqual(request.META['SCRIPT_NAME'], '')
29 28
 
30 29
     def test_modpythonrequest(self):
31 30
         class FakeModPythonRequest(ModPythonRequest):
@@ -39,23 +38,22 @@ def get_options(self):
39 38
 
40 39
         req = Dummy()
41 40
         req.uri = 'bogus'
42  
-        self.assertEquals(repr(FakeModPythonRequest(req)),
43  
-            "<ModPythonRequest\n"\
44  
-            "path:bogus,\n"\
45  
-            "GET:{},\n"\
46  
-            "POST:{},\n"\
47  
-            "COOKIES:{},\n"\
48  
-            "META:{}>")
  41
+        request = FakeModPythonRequest(req)
  42
+        self.assertEqual(request.path, 'bogus')
  43
+        self.assertEqual(request.GET.keys(), [])
  44
+        self.assertEqual(request.POST.keys(), [])
  45
+        self.assertEqual(request.COOKIES.keys(), [])
  46
+        self.assertEqual(request.META.keys(), [])
49 47
 
50 48
     def test_parse_cookie(self):
51  
-        self.assertEquals(parse_cookie('invalid:key=true'), {})
  49
+        self.assertEqual(parse_cookie('invalid:key=true'), {})
52 50
 
53 51
     def test_httprequest_location(self):
54 52
         request = HttpRequest()
55  
-        self.assertEquals(request.build_absolute_uri(location="https://www.example.com/asdf"),
  53
+        self.assertEqual(request.build_absolute_uri(location="https://www.example.com/asdf"),
56 54
             'https://www.example.com/asdf')
57 55
 
58 56
         request.get_host = lambda: 'www.example.com'
59 57
         request.path = ''
60  
-        self.assertEquals(request.build_absolute_uri(location="/path/with:colons"),
  58
+        self.assertEqual(request.build_absolute_uri(location="/path/with:colons"),
61 59
             'http://www.example.com/path/with:colons')

0 notes on commit aec5f08

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