From: Kenneth Reitz Date: Wed, 17 Aug 2011 03:58:55 +0000 (-0400) Subject: cleanups X-Git-Tag: v0.6.0~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9322d13f610fc26f63cc51c8c4b0a907d7392153;p=services%2Fpython-requests.git cleanups --- diff --git a/test_requests.py b/test_requests.py index d6f948e..dd92347 100755 --- a/test_requests.py +++ b/test_requests.py @@ -13,7 +13,7 @@ except ImportError: import requests -from requests.session import Session +from requests.sessions import Session HTTPBIN_URL = 'http://httpbin.org/' @@ -132,22 +132,21 @@ class RequestsTestSuite(unittest.TestCase): self.assertEqual(r.status_code, 200) - def test_AUTH_HTTPS_200_OK_GET(self): + def test_AUTH_HTTP_200_OK_GET(self): for service in SERVICES: auth = ('user', 'pass') url = service('basic-auth', 'user', 'pass') - r = requests.get(url, auth=auth) + r = requests.get(url, auth=auth) + # print r.__dict__ self.assertEqual(r.status_code, 200) + r = requests.get(url) self.assertEqual(r.status_code, 200) - # reset auto authentication - requests.auth_manager.empty() - def test_POSTBIN_GET_POST_FILES(self): @@ -245,21 +244,6 @@ class RequestsTestSuite(unittest.TestCase): r.content.decode('ascii') - def test_autoauth(self): - - http_auth = ('user', 'pass') - requests.auth_manager.add_auth('httpbin.org', http_auth) - - r = requests.get(httpbin('basic-auth', 'user', 'pass')) - self.assertEquals(r.status_code, 200) - - - requests.auth_manager.add_auth('httpbin.ep.io', http_auth) - - r = requests.get(httpsbin('basic-auth', 'user', 'pass')) - self.assertEquals(r.status_code, 200) - - def test_unicode_get(self): for service in SERVICES: @@ -457,27 +441,35 @@ class RequestsTestSuite(unittest.TestCase): 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') + r1 = s.get(httpbin('user-agent')) + assert heads['User-agent'] in r1.content - r2 = s.get(httpbin('user-agent') + r2 = s.get(httpbin('user-agent')) + assert heads['User-agent'] in r2.content - self.assertEqual(r.status_code, 200) - - + self.assertEqual(r2.status_code, 200) + + if __name__ == '__main__': unittest.main()