Test async requests with Session cookies
authorRoman Haritonov <reclosedev@gmail.com>
Tue, 8 May 2012 08:55:36 +0000 (12:55 +0400)
committerRoman Haritonov <reclosedev@gmail.com>
Tue, 8 May 2012 08:55:36 +0000 (12:55 +0400)
tests/test_requests_async.py

index 3a5a762eb565729508803aeb238180d900e6ce8a..892472cf7763dfdb326ed94e3358305707e51d61 100755 (executable)
@@ -12,6 +12,7 @@ import select
 has_poll = hasattr(select, "poll")
 
 from requests import async
+import requests
 
 sys.path.append('.')
 from test_requests import httpbin, RequestsTestSuite, SERVICES
@@ -63,5 +64,14 @@ class RequestsTestSuiteUsingAsyncApi(RequestsTestSuite):
         """Test to make sure we don't overwrite the poll"""
         self.assertEqual(hasattr(select, "poll"), has_poll)
 
+    def test_async_with_session_cookies(self):
+        s = requests.Session(cookies={'initial': '42'})
+        r1 = get(httpbin('cookies/set/async/yes'), session=s)
+        r2 = get(httpbin('cookies/set/no_session/yes'))
+        assert 'initial' in r1.cookies
+        assert 'initial' not in r2.cookies and 'async' not in r2.cookies
+        assert 'async' in s.cookies
+        assert 'no_session' not in s.cookies
+
 if __name__ == '__main__':
     unittest.main()