ultra cookie compatibility
authorKenneth Reitz <me@kennethreitz.com>
Thu, 10 Nov 2011 00:25:20 +0000 (16:25 -0800)
committerKenneth Reitz <me@kennethreitz.com>
Thu, 10 Nov 2011 00:26:15 +0000 (16:26 -0800)
requests/models.py
test_requests.py

index 734e0b8..c04e4c5 100644 (file)
@@ -246,11 +246,7 @@ class Request(object):
 
         self.response = r
         self.response.request = self
-        # print locals()
         self.response.cookies.update(self.cookies)
-        # print cookies
-        # print self.response.cookies
-        # print '!!!'
 
 
     @staticmethod
index 8b0f7c7..40fa82e 100755 (executable)
@@ -490,11 +490,24 @@ class RequestsTestSuite(unittest.TestCase):
         del _c['bessie']
         assert c == _c
 
-
+        # Test session-level cookies.
         s = requests.session(cookies=_c)
+        r = s.get(httpbin('cookies'))
         c = json.loads(r.content).get('cookies')
         assert c == _c
 
+        # Have the server set a cookie.
+        r = s.get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True)
+        c = json.loads(r.content).get('cookies')
+
+        assert 'k' in c
+
+        # And server-set cookie persistience.
+        r = s.get(httpbin('cookies'))
+        c = json.loads(r.content).get('cookies')
+
+        assert 'k' in c
+
 
 
     def test_session_persistent_params(self):
@@ -524,17 +537,6 @@ class RequestsTestSuite(unittest.TestCase):
         assert params3['b'] in r3.content
         assert params3['c'] in r3.content
 
-
-    def test_cookies(self):
-
-        s = requests.session()
-        r = s.get(httpbin('cookies', 'set', 'face', 'book'))
-        # print r.headers
-        # print r.history[0].cookies
-        # print r.content
-        # print r.url
-
-
     def test_invalid_content(self):
 
         # WARNING: if you're using a terrible DNS provider (comcast),