mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Added tests for requests.session
This commit is contained in:
@@ -13,6 +13,7 @@ except ImportError:
|
||||
|
||||
import requests
|
||||
|
||||
from requests.session import Session
|
||||
|
||||
|
||||
HTTPBIN_URL = 'http://httpbin.org/'
|
||||
@@ -455,5 +456,28 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
self.assertEquals(len(r.history), 3)
|
||||
|
||||
|
||||
def test_session_HTTP_200_OK_GET(self):
|
||||
s = Session()
|
||||
r = s.get(httpbin('/'))
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
def test_session_HTTPS_200_OK_GET(self):
|
||||
s = Session()
|
||||
r = s.get(httpsbin('/'))
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
def test_session_persistent_headers(self):
|
||||
heads = {'User-agent': 'Mozilla/5.0'}
|
||||
s = Session()
|
||||
s.headers = heads
|
||||
# Make 2 requests from Session object, should send header both times
|
||||
r1 = s.get(httpbin('user-agent')
|
||||
assert heads['User-agent'] in r1.content
|
||||
r2 = s.get(httpbin('user-agent')
|
||||
assert heads['User-agent'] in r2.content
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user