Skip to content
Myr

Added tests for requests.session

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Hogans · committed by Tom Hogans · parent ca42850 · Browse files · 1 file+24 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−0 removed

  • other:+24 added−0 removed

1 file+24 added−0 removed

modified:test_requests.py+24 added
11 unmodified lines
12 import json1314import requests1516from requests.session import Session171819HTTPBIN_URL = 'http://httpbin.org/'20HTTPSBIN_URL = 'https://httpbin.ep.io/'
434 unmodified lines
455 self.assertEquals(r.status_code, 200)456 self.assertEquals(len(r.history), 3)457458459 def test_session_HTTP_200_OK_GET(self):460 s = Session()461 r = s.get(httpbin('/'))462 self.assertEqual(r.status_code, 200)463464 def test_session_HTTPS_200_OK_GET(self):465 s = Session()466 r = s.get(httpsbin('/'))467 self.assertEqual(r.status_code, 200)468469 def test_session_persistent_headers(self):470 heads = {'User-agent': 'Mozilla/5.0'}471 s = Session()472 s.headers = heads473 # Make 2 requests from Session object, should send header both times474 r1 = s.get(httpbin('user-agent')475 assert heads['User-agent'] in r1.content476 r2 = s.get(httpbin('user-agent')477 assert heads['User-agent'] in r2.content478 self.assertEqual(r.status_code, 200)479 480 481482if __name__ == '__main__':483 unittest.main()