test_requests.py
This file
Path
test_requests.py
459 lines · 12.5 KiB · Python
Last changed by
test relative redirectsKenneth Reitzbefore adoptionb141da3
History of this fileTake it
The walk stopped after 200 commits: lines older than 800b034 point at it.
whitespaceKenneth Reitzbefore adoption800b034
lines 1–3why, one step back1#!/usr/bin/env python2# -*- coding: utf-8 -*-3python2.5 withKenneth Reitzbefore adoption06e662b
lines 4–5why, one step back4from __future__ import with_statement5whitespaceKenneth Reitzbefore adoption800b034
line 6why, one step back6import unittestMerge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 7why, one step back7import cookielibomnijson for testsKenneth Reitzbefore adoptionbdf9f90
line 8why, one step back8Merge branch 'develop' of https://github.com/tgulacsi/requests into developKenneth Reitzbefore adoption6ba3523
lines 9–11why, one step back9try:10 import omnijson as json11except ImportError:fixing bad url shortner linkKenneth Reitzbefore adoption2edda29
line 12why, one step back12 import jsonwhitespaceKenneth Reitzbefore adoption800b034
lines 13–16why, one step back1314import requests1516Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
lines 17–20why, one step back1718HTTPBIN_URL = 'http://httpbin.org/'19HTTPSBIN_URL = 'https://httpbin.ep.io/'20proper PATCH testingKenneth Reitzbefore adoption8c81cf6
lines 21–22why, one step back21# HTTPBIN_URL = 'http://staging.httpbin.org/'22# HTTPSBIN_URL = 'https://httpbin-staging.ep.io/'Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
lines 23–33why, one step back232425def httpbin(*suffix):26 """Returns url for HTTPBIN resource."""2728 return HTTPBIN_URL + '/'.join(suffix)293031def httpsbin(*suffix):32 """Returns url for HTTPSBIN resource."""33Actually use the HTTPSBIN variable for test https requestsRichard Boultonbefore adoption4320f81
line 34why, one step back34 return HTTPSBIN_URL + '/'.join(suffix)Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
lines 35–36why, one step back3536http/https testsKenneth Reitzbefore adoptionbb16fe8
line 37why, one step back37SERVICES = (httpbin, httpsbin)Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 38why, one step back38http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 39–40why, one step back3940whitespaceKenneth Reitzbefore adoption800b034
line 41why, one step back41class RequestsTestSuite(unittest.TestCase):Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 42why, one step back42 """Requests test cases."""Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 43why, one step back43Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 44why, one step back44Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
lines 45–46why, one step back45 def setUp(self):46 passwhitespaceKenneth Reitzbefore adoption800b034
line 47why, one step back47WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 48why, one step back48Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
lines 49–51why, one step back49 def tearDown(self):50 """Teardown."""51 passMerge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 52why, one step back52WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 53why, one step back53Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
lines 54–55why, one step back54 def test_invalid_url(self):55 self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')whitespaceKenneth Reitzbefore adoption800b034
line 56why, one step back56WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 57why, one step back57Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 58why, one step back58 def test_HTTP_200_OK_GET(self):Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 59why, one step back59 r = requests.get(httpbin('/'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 60why, one step back60 self.assertEqual(r.status_code, 200)whitespaceKenneth Reitzbefore adoption800b034
line 61why, one step back61WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 62why, one step back62Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 63why, one step back63 def test_HTTPS_200_OK_GET(self):Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 64why, one step back64 r = requests.get(httpsbin('/'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 65why, one step back65 self.assertEqual(r.status_code, 200)whitespaceKenneth Reitzbefore adoption800b034
line 66why, one step back66WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 67why, one step back67Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
lines 68–69why, one step back68 def test_HTTP_200_OK_GET_WITH_PARAMS(self):69 heads = {'User-agent': 'Mozilla/5.0'}test for gzip decompressKenneth Reitzbefore adoption1359094
line 70why, one step back70Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 71why, one step back71 r = requests.get(httpbin('user-agent'), headers=heads)Merge branch 'develop' of git://github.com/kennethreitz/requests into developZbigniew Siciarzbefore adoptionfade9e3
lines 72–73why, one step back7273 assert heads['User-agent'] in r.contentMerge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
lines 74–75why, one step back74 self.assertEqual(r.status_code, 200)75WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 76why, one step back76Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
lines 77–79why, one step back77 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):78 heads = {'User-agent': 'Mozilla/5.0'}79Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 80why, one step back80 r = requests.get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 81why, one step back81 self.assertEqual(r.status_code, 200)Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 82why, one step back82WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 83why, one step back83Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
lines 84–85why, one step back84 def test_user_agent_transfers(self):85 """Issue XX"""Merge branch 'develop' of git://github.com/kennethreitz/requests into developZbigniew Siciarzbefore adoptionfade9e3
line 86why, one step back86useragentKenneth Reitzbefore adoption8a4d5c4
lines 87–90why, one step back87 heads = {88 'User-agent':89 'Mozilla/5.0 (github.com/kennethreitz/requests)'90 }Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 91why, one step back91Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 92why, one step back92 r = requests.get(httpbin('user-agent'), headers=heads);Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 93why, one step back93 self.assertTrue(heads['User-agent'] in r.content)useragentKenneth Reitzbefore adoption8a4d5c4
lines 94–99why, one step back9495 heads = {96 'user-agent':97 'Mozilla/5.0 (github.com/kennethreitz/requests)'98 }99Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 100why, one step back100 r = requests.get(httpbin('user-agent'), headers=heads);useragentKenneth Reitzbefore adoption8a4d5c4
line 101why, one step back101 self.assertTrue(heads['user-agent'] in r.content)test for gzip decompressKenneth Reitzbefore adoption1359094
line 102why, one step back102WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 103why, one step back103Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 104why, one step back104 def test_HTTP_200_OK_HEAD(self):Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 105why, one step back105 r = requests.head(httpbin('/'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 106why, one step back106 self.assertEqual(r.status_code, 200)whitespaceKenneth Reitzbefore adoption800b034
line 107why, one step back107WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 108why, one step back108Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 109why, one step back109 def test_HTTPS_200_OK_HEAD(self):Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 110why, one step back110 r = requests.head(httpsbin('/'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 111why, one step back111 self.assertEqual(r.status_code, 200)whitespaceKenneth Reitzbefore adoption800b034
line 112why, one step back112WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 113why, one step back113proper PATCH testingKenneth Reitzbefore adoption8c81cf6
lines 114–133why, one step back114 def test_HTTP_200_OK_PUT(self):115 r = requests.put(httpbin('put'))116 self.assertEqual(r.status_code, 200)117118119 def test_HTTPS_200_OK_PUT(self):120 r = requests.put(httpsbin('put'))121 self.assertEqual(r.status_code, 200)122123124 def test_HTTP_200_OK_PATCH(self):125 r = requests.patch(httpbin('patch'))126 self.assertEqual(r.status_code, 200)127128129 def test_HTTPS_200_OK_PATCH(self):130 r = requests.patch(httpsbin('patch'))131 self.assertEqual(r.status_code, 200)132133Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 134why, one step back134 def test_AUTH_HTTPS_200_OK_GET(self):whitespaceKenneth Reitzbefore adoption800b034
line 135why, one step back135http/https testsKenneth Reitzbefore adoptionbb16fe8
line 136why, one step back136 for service in SERVICES:Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4
line 137why, one step back137http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 138–140why, one step back138 auth = ('user', 'pass')139 url = service('basic-auth', 'user', 'pass')140 r = requests.get(url, auth=auth)Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa
line 141why, one step back141http/https testsKenneth Reitzbefore adoptionbb16fe8
line 142why, one step back142 self.assertEqual(r.status_code, 200)Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa
line 143why, one step back143http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 144–145why, one step back144 r = requests.get(url)145 self.assertEqual(r.status_code, 200)WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 146why, one step back146http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 147–150why, one step back147 # reset auto authentication148 requests.auth_manager.empty()149150Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 151why, one step back151 def test_POSTBIN_GET_POST_FILES(self):test for gzip decompressKenneth Reitzbefore adoption1359094
line 152why, one step back152http/https testsKenneth Reitzbefore adoptionbb16fe8
line 153why, one step back153 for service in SERVICES:Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4
line 154why, one step back154http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 155–156why, one step back155 url = service('post')156 post = requests.post(url).raise_for_status()Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4
line 157why, one step back157http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 158–159why, one step back158 post = requests.post(url, data={'some': 'data'})159 self.assertEqual(post.status_code, 200)Merge pull request #29 from meganemura/requestsKenneth Reitzbefore adoption9b0bb87
line 160why, one step back160http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 161–162why, one step back161 post2 = requests.post(url, files={'some': open('test_requests.py')})162 self.assertEqual(post2.status_code, 200)Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 163why, one step back163http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 164–167why, one step back164 post3 = requests.post(url, data='[{"some": "json"}]')165 self.assertEqual(post3.status_code, 200)166167Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 168why, one step back168 def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):test for gzip decompressKenneth Reitzbefore adoption1359094
line 169why, one step back169http/https testsKenneth Reitzbefore adoptionbb16fe8
line 170why, one step back170 for service in SERVICES:Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 171why, one step back171http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 172–175why, one step back172 url = service('post')173 post = requests.post(url,174 files={'some': open('test_requests.py')},175 data={'some': 'data'})Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 176why, one step back176http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 177–179why, one step back177 self.assertEqual(post.status_code, 200)178179Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
lines 180–181why, one step back180 def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):181http/https testsKenneth Reitzbefore adoptionbb16fe8
line 182why, one step back182 for service in SERVICES:Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 183why, one step back183http/https testsKenneth Reitzbefore adoptionbb16fe8
line 184why, one step back184 url = service('post')Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 185why, one step back185http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 186–188why, one step back186 post2 = requests.post(url,187 files={'some': open('test_requests.py')},188 headers = {'User-Agent': 'requests-tests'})test for gzip decompressKenneth Reitzbefore adoption1359094
line 189why, one step back189http/https testsKenneth Reitzbefore adoptionbb16fe8
line 190why, one step back190 self.assertEqual(post2.status_code, 200)Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 191why, one step back191http/https testsKenneth Reitzbefore adoptionbb16fe8
line 192why, one step back192Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 193why, one step back193 def test_nonzero_evaluation(self):test for gzip decompressKenneth Reitzbefore adoption1359094
line 194why, one step back194http/https testsKenneth Reitzbefore adoptionbb16fe8
line 195why, one step back195 for service in SERVICES:test for gzip decompressKenneth Reitzbefore adoption1359094
line 196why, one step back196http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 197–198why, one step back197 r = requests.get(service('status', '500'))198 self.assertEqual(bool(r), False)WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 199why, one step back199http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 200–203why, one step back200 r = requests.get(service('/'))201 self.assertEqual(bool(r), True)202203Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 204why, one step back204 def test_request_ok_set(self):test for gzip decompressKenneth Reitzbefore adoption1359094
line 205why, one step back205http/https testsKenneth Reitzbefore adoptionbb16fe8
line 206why, one step back206 for service in SERVICES:WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 207why, one step back207http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 208–211why, one step back208 r = requests.get(service('status', '404'))209 self.assertEqual(r.ok, False)210211Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 212why, one step back212 def test_status_raising(self):Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 213why, one step back213 r = requests.get(httpbin('status', '404'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 214why, one step back214 self.assertRaises(requests.HTTPError, r.raise_for_status)test for gzip decompressKenneth Reitzbefore adoption1359094
line 215why, one step back215Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 216why, one step back216 r = requests.get(httpbin('status', '200'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
lines 217–218why, one step back217 self.assertFalse(r.error)218 r.raise_for_status()test for gzip decompressKenneth Reitzbefore adoption1359094
line 219why, one step back219WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 220why, one step back220Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 221why, one step back221 def test_cookie_jar(self):Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 222why, one step back222Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
lines 223–224why, one step back223 jar = cookielib.CookieJar()224 self.assertFalse(jar)Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 225why, one step back225Porting cookie test to httpbin.org.Zbigniew Siciarzbefore adoption4d3a9de
lines 226–227why, one step back226 url = httpbin('cookies', 'set', 'requests_cookie', 'awesome')227 r = requests.get(url, cookies=jar)Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 228why, one step back228 self.assertTrue(jar)Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 229why, one step back229Testing that cookies actually work.Zbigniew Siciarzbefore adoption54fd24b
lines 230–235why, one step back230 cookie_found = False231 for cookie in jar:232 if cookie.name == 'requests_cookie':233 self.assertEquals(cookie.value, 'awesome')234 cookie_found = True235 self.assertTrue(cookie_found)Porting cookie test to httpbin.org.Zbigniew Siciarzbefore adoption4d3a9de
lines 236–238why, one step back236237 r = requests.get(httpbin('cookies'), cookies=jar)238 self.assertTrue('awesome' in r.content)Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 239why, one step back239WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 240why, one step back240test for gzip decompressKenneth Reitzbefore adoption1359094
line 241why, one step back241 def test_decompress_gzip(self):whitespaceKenneth Reitzbefore adoption800b034
line 242why, one step back242Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 243why, one step back243 r = requests.get(httpbin('gzip'))test for gzip decompressKenneth Reitzbefore adoption1359094
line 244why, one step back244 r.content.decode('ascii')add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9
line 245why, one step back245WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 246why, one step back246add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9
lines 247–248why, one step back247 def test_autoauth(self):248Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
lines 249–250why, one step back249 http_auth = ('user', 'pass')250 requests.auth_manager.add_auth('httpbin.org', http_auth)add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9
line 251why, one step back251Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 252why, one step back252 r = requests.get(httpbin('basic-auth', 'user', 'pass'))add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9
line 253why, one step back253 self.assertEquals(r.status_code, 200)whitespaceKenneth Reitzbefore adoption800b034
line 254why, one step back254WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 255why, one step back255http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 256–261why, one step back256 requests.auth_manager.add_auth('httpbin.ep.io', http_auth)257258 r = requests.get(httpsbin('basic-auth', 'user', 'pass'))259 self.assertEquals(r.status_code, 200)260261test for unicode url issuesKenneth Reitzbefore adoption8a4a05a
line 262why, one step back262 def test_unicode_get(self):WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 263why, one step back263http/https testsKenneth Reitzbefore adoptionbb16fe8
line 264why, one step back264 for service in SERVICES:test for unicode url issuesKenneth Reitzbefore adoption8a4a05a
line 265why, one step back265http/https testsKenneth Reitzbefore adoptionbb16fe8
line 266why, one step back266 url = service('/')WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 267why, one step back267http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 268–272why, one step back268 requests.get(url, params={'foo': u'føø'})269 requests.get(url, params={u'føø': u'føø'})270 requests.get(url, params={'føø': 'føø'})271 requests.get(url, params={'foo': u'foo'})272 requests.get(service('ø'), params={'foo': u'foo'})Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 273why, one step back273http/https testsKenneth Reitzbefore adoptionbb16fe8
line 274why, one step back274HTTP Basic recursion. Fixes #31Kenneth Reitzbefore adoption1421ffa
line 275why, one step back275 def test_httpauth_recursion(self):http/https testsKenneth Reitzbefore adoptionbb16fe8
line 276why, one step back276Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
line 277why, one step back277 http_auth = ('user', 'BADpass')HTTP Basic recursion. Fixes #31Kenneth Reitzbefore adoption1421ffa
line 278why, one step back278http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 279–281why, one step back279 for service in SERVICES:280 r = requests.get(service('basic-auth', 'user', 'pass'), auth=http_auth)281 self.assertEquals(r.status_code, 401)Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 282why, one step back282WHITESPACEKenneth Reitzbefore adoption1fa1cdd
line 283why, one step back283Add tests for settingsJohannes Gorsetbefore adoption21e2d0c
line 284why, one step back284 def test_settings(self):Timeouts are normal errors now.Kenneth Reitzbefore adoption162b751
lines 285–289why, one step back285286 def test():287 r = requests.get(httpbin(''))288 r.raise_for_status()289rackspace cloud's net connection is insaneKenneth Reitzbefore adoption74013d7
line 290why, one step back290 with requests.settings(timeout=0.0000001):Timeouts are normal errors now.Kenneth Reitzbefore adoption162b751
line 291why, one step back291 self.assertRaises(requests.Timeout, test)Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 292why, one step back292Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117
lines 293–294why, one step back293 with requests.settings(timeout=100):294 requests.get(httpbin(''))whitespaceKenneth Reitzbefore adoptioncd0d0a2
line 295why, one step back295Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 296why, one step back296Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
lines 297–298why, one step back297 def test_urlencoded_post_data(self):298http/https testsKenneth Reitzbefore adoptionbb16fe8
line 299why, one step back299 for service in SERVICES:Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 300why, one step back300http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 301–312why, one step back301 r = requests.post(service('post'), data=dict(test='fooaowpeuf'))302303 self.assertEquals(r.status_code, 200)304 self.assertEquals(r.headers['content-type'], 'application/json')305 self.assertEquals(r.url, service('post'))306307 rbody = json.loads(r.content)308309 self.assertEquals(rbody.get('form'), dict(test='fooaowpeuf'))310 self.assertEquals(rbody.get('data'), '')311312Add test for non-urlencoded post dataJohannes Gorsetbefore adoption637d033
line 313why, one step back313 def test_nonurlencoded_post_data(self):Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 314why, one step back314http/https testsKenneth Reitzbefore adoptionbb16fe8
line 315why, one step back315 for service in SERVICES:Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 316why, one step back316http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 317–329why, one step back317 r = requests.post(service('post'), data='fooaowpeuf')318319 self.assertEquals(r.status_code, 200)320 self.assertEquals(r.headers['content-type'], 'application/json')321 self.assertEquals(r.url, service('post'))322323 rbody = json.loads(r.content)324 # Body wasn't valid url encoded data, so the server returns None as325 # "form" and the raw body as "data".326 self.assertEquals(rbody.get('form'), None)327 self.assertEquals(rbody.get('data'), 'fooaowpeuf')328329Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
lines 330–331why, one step back330 def test_urlencoded_post_querystring(self):331http/https testsKenneth Reitzbefore adoptionbb16fe8
line 332why, one step back332 for service in SERVICES:Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 333why, one step back333http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 334–344why, one step back334 r = requests.post(service('post'), params=dict(test='fooaowpeuf'))335336 self.assertEquals(r.status_code, 200)337 self.assertEquals(r.headers['content-type'], 'application/json')338 self.assertEquals(r.url, service('post?test=fooaowpeuf'))339340 rbody = json.loads(r.content)341 self.assertEquals(rbody.get('form'), {}) # No form supplied342 self.assertEquals(rbody.get('data'), '')343344Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
lines 345–346why, one step back345 def test_nonurlencoded_post_querystring(self):346http/https testsKenneth Reitzbefore adoptionbb16fe8
line 347why, one step back347 for service in SERVICES:Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 348why, one step back348http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 349–359why, one step back349 r = requests.post(service('post'), params='fooaowpeuf')350351 self.assertEquals(r.status_code, 200)352 self.assertEquals(r.headers['content-type'], 'application/json')353 self.assertEquals(r.url, service('post?fooaowpeuf'))354355 rbody = json.loads(r.content)356 self.assertEquals(rbody.get('form'), {}) # No form supplied357 self.assertEquals(rbody.get('data'), '')358359Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
lines 360–361why, one step back360 def test_urlencoded_post_query_and_data(self):361http/https testsKenneth Reitzbefore adoptionbb16fe8
line 362why, one step back362 for service in SERVICES:Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 363why, one step back363http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 364–377why, one step back364 r = requests.post(365 service('post'),366 params=dict(test='fooaowpeuf'),367 data=dict(test2="foobar"))368369 self.assertEquals(r.status_code, 200)370 self.assertEquals(r.headers['content-type'], 'application/json')371 self.assertEquals(r.url, service('post?test=fooaowpeuf'))372373 rbody = json.loads(r.content)374 self.assertEquals(rbody.get('form'), dict(test2='foobar'))375 self.assertEquals(rbody.get('data'), '')376377Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d
line 378why, one step back378 def test_nonurlencoded_post_query_and_data(self):Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94
line 379why, one step back379http/https testsKenneth Reitzbefore adoptionbb16fe8
line 380why, one step back380 for service in SERVICES:whitespace!Kenneth Reitzbefore adoptiona987729
line 381why, one step back381http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 382–394why, one step back382 r = requests.post(service('post'),383 params='fooaowpeuf', data="foobar")384385 self.assertEquals(r.status_code, 200)386 self.assertEquals(r.headers['content-type'], 'application/json')387 self.assertEquals(r.url, service('post?fooaowpeuf'))388389 rbody = json.loads(r.content)390391 self.assertEquals(rbody.get('form'), None)392 self.assertEquals(rbody.get('data'), 'foobar')393394Implemented idna (fixes #76).Jérémy Bethmontbefore adoption868cd3d
lines 395–396why, one step back395 def test_idna(self):396 r = requests.get(u'http://➡.ws/httpbin')test fixKenneth Reitzbefore adoption074150f
line 397why, one step back397 assert 'httpbin' in r.urlHTTP Basic recursion. Fixes #31Kenneth Reitzbefore adoption1421ffa
line 398why, one step back398whitespace!Kenneth Reitzbefore adoptiona987729
line 399why, one step back399Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190
lines 400–401why, one step back400 def test_urlencoded_get_query_multivalued_param(self):401http/https testsKenneth Reitzbefore adoptionbb16fe8
line 402why, one step back402 for service in SERVICES:whitespace!Kenneth Reitzbefore adoptiona987729
line 403why, one step back403http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 404–408why, one step back404 r = requests.get(service('get'), params=dict(test=['foo','baz']))405 self.assertEquals(r.status_code, 200)406 self.assertEquals(r.url, service('get?test=foo&test=baz'))407408Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190
line 409why, one step back409 def test_urlencoded_post_querystring_multivalued(self):whitespace!Kenneth Reitzbefore adoptiona987729
line 410why, one step back410http/https testsKenneth Reitzbefore adoptionbb16fe8
line 411why, one step back411 for service in SERVICES:Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190
line 412why, one step back412http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 413–422why, one step back413 r = requests.post(service('post'), params=dict(test=['foo','baz']))414 self.assertEquals(r.status_code, 200)415 self.assertEquals(r.headers['content-type'], 'application/json')416 self.assertEquals(r.url, service('post?test=foo&test=baz'))417418 rbody = json.loads(r.content)419 self.assertEquals(rbody.get('form'), {}) # No form supplied420 self.assertEquals(rbody.get('data'), '')421422Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190
lines 423–424why, one step back423 def test_urlencoded_post_query_multivalued_and_data(self):424http/https testsKenneth Reitzbefore adoptionbb16fe8
line 425why, one step back425 for service in SERVICES:test for unicode url issuesKenneth Reitzbefore adoption8a4a05a
line 426why, one step back426http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 427–439why, one step back427 r = requests.post(428 service('post'),429 params=dict(test=['foo','baz']),430 data=dict(test2="foobar",test3=['foo','baz']))431432 self.assertEquals(r.status_code, 200)433 self.assertEquals(r.headers['content-type'], 'application/json')434 self.assertEquals(r.url, service('post?test=foo&test=baz'))435 rbody = json.loads(r.content)436 self.assertEquals(rbody.get('form'), dict(test2='foobar',test3='foo'))437 self.assertEquals(rbody.get('data'), '')438439redirect history length testKenneth Reitzbefore adoption87560d6
lines 440–441why, one step back440 def test_redirect_history(self):441http/https testsKenneth Reitzbefore adoptionbb16fe8
lines 442–448why, one step back442 for service in SERVICES:443444 r = requests.get(service('redirect', '3'))445 self.assertEquals(r.status_code, 200)446 self.assertEquals(len(r.history), 3)447448test relative redirectsKenneth Reitzbefore adoptionb141da3
lines 449–456why, one step back449 def test_relative_redirect_history(self):450451 for service in SERVICES:452453 r = requests.get(service('relative-redirect', '3'))454 self.assertEquals(r.status_code, 200)455 self.assertEquals(len(r.history), 3)456redirect history length testKenneth Reitzbefore adoption87560d6
line 457why, one step back457whitespaceKenneth Reitzbefore adoption800b034
line 458why, one step back458if __name__ == '__main__':Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 459why, one step back459 unittest.main()