Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 800b034 point at it.

whitespaceKenneth Reitzbefore adoption800b034

lines 1–3why, one step back
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-3

python2.5 withKenneth Reitzbefore adoption06e662b

lines 4–5why, one step back
4from __future__ import with_statement
5

whitespaceKenneth Reitzbefore adoption800b034

line 6why, one step back
6import unittest

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 7why, one step back
7import cookielib

omnijson for testsKenneth Reitzbefore adoptionbdf9f90

line 8why, one step back
8

Merge branch 'develop' of https://github.com/tgulacsi/requests into developKenneth Reitzbefore adoption6ba3523

lines 9–11why, one step back
9try:
10 import omnijson as json11except ImportError:

fixing bad url shortner linkKenneth Reitzbefore adoption2edda29

line 12why, one step back
12 import json

whitespaceKenneth Reitzbefore adoption800b034

lines 13–16why, one step back
13
14import requests1516

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

lines 17–20why, one step back
17
18HTTPBIN_URL = 'http://httpbin.org/'19HTTPSBIN_URL = 'https://httpbin.ep.io/'20

proper PATCH testingKenneth Reitzbefore adoption8c81cf6

lines 21–22why, one step back
21# 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 back
23
2425def httpbin(*suffix):26 """Returns url for HTTPBIN resource."""2728 return HTTPBIN_URL + '/'.join(suffix)293031def httpsbin(*suffix):32 """Returns url for HTTPSBIN resource."""33

Actually use the HTTPSBIN variable for test https requestsRichard Boultonbefore adoption4320f81

line 34why, one step back
34 return HTTPSBIN_URL + '/'.join(suffix)

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

lines 35–36why, one step back
35
36

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 37why, one step back
37SERVICES = (httpbin, httpsbin)

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 38why, one step back
38

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 39–40why, one step back
39
40

whitespaceKenneth Reitzbefore adoption800b034

line 41why, one step back
41class RequestsTestSuite(unittest.TestCase):

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 42why, one step back
42 """Requests test cases."""

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 43why, one step back
43

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 44why, one step back
44

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

lines 45–46why, one step back
45 def setUp(self):
46 pass

whitespaceKenneth Reitzbefore adoption800b034

line 47why, one step back
47

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 48why, one step back
48

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

lines 49–51why, one step back
49 def tearDown(self):
50 """Teardown."""51 pass

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 52why, one step back
52

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 53why, one step back
53

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

lines 54–55why, one step back
54 def test_invalid_url(self):
55 self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')

whitespaceKenneth Reitzbefore adoption800b034

line 56why, one step back
56

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 57why, one step back
57

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 58why, one step back
58 def test_HTTP_200_OK_GET(self):

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 59why, one step back
59 r = requests.get(httpbin('/'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 60why, one step back
60 self.assertEqual(r.status_code, 200)

whitespaceKenneth Reitzbefore adoption800b034

line 61why, one step back
61

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 62why, one step back
62

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 63why, one step back
63 def test_HTTPS_200_OK_GET(self):

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 64why, one step back
64 r = requests.get(httpsbin('/'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 65why, one step back
65 self.assertEqual(r.status_code, 200)

whitespaceKenneth Reitzbefore adoption800b034

line 66why, one step back
66

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 67why, one step back
67

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

lines 68–69why, one step back
68 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 back
70

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 71why, one step back
71 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 back
72
73 assert heads['User-agent'] in r.content

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

lines 74–75why, one step back
74 self.assertEqual(r.status_code, 200)
75

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 76why, one step back
76

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

lines 77–79why, one step back
77 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):
78 heads = {'User-agent': 'Mozilla/5.0'}79

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 80why, one step back
80 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 back
81 self.assertEqual(r.status_code, 200)

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 82why, one step back
82

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 83why, one step back
83

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

lines 84–85why, one step back
84 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 back
86

useragentKenneth Reitzbefore adoption8a4d5c4

lines 87–90why, one step back
87 heads = {
88 'User-agent':89 'Mozilla/5.0 (github.com/kennethreitz/requests)'90 }

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 91why, one step back
91

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 92why, one step back
92 r = requests.get(httpbin('user-agent'), headers=heads);

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 93why, one step back
93 self.assertTrue(heads['User-agent'] in r.content)

useragentKenneth Reitzbefore adoption8a4d5c4

lines 94–99why, one step back
94
95 heads = {96 'user-agent':97 'Mozilla/5.0 (github.com/kennethreitz/requests)'98 }99

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 100why, one step back
100 r = requests.get(httpbin('user-agent'), headers=heads);

useragentKenneth Reitzbefore adoption8a4d5c4

line 101why, one step back
101 self.assertTrue(heads['user-agent'] in r.content)

test for gzip decompressKenneth Reitzbefore adoption1359094

line 102why, one step back
102

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 103why, one step back
103

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 104why, one step back
104 def test_HTTP_200_OK_HEAD(self):

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 105why, one step back
105 r = requests.head(httpbin('/'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 106why, one step back
106 self.assertEqual(r.status_code, 200)

whitespaceKenneth Reitzbefore adoption800b034

line 107why, one step back
107

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 108why, one step back
108

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 109why, one step back
109 def test_HTTPS_200_OK_HEAD(self):

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 110why, one step back
110 r = requests.head(httpsbin('/'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 111why, one step back
111 self.assertEqual(r.status_code, 200)

whitespaceKenneth Reitzbefore adoption800b034

line 112why, one step back
112

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 113why, one step back
113

proper PATCH testingKenneth Reitzbefore adoption8c81cf6

lines 114–133why, one step back
114 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)132133

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 134why, one step back
134 def test_AUTH_HTTPS_200_OK_GET(self):

whitespaceKenneth Reitzbefore adoption800b034

line 135why, one step back
135

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 136why, one step back
136 for service in SERVICES:

Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4

line 137why, one step back
137

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 138–140why, one step back
138 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 back
141

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 142why, one step back
142 self.assertEqual(r.status_code, 200)

Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa

line 143why, one step back
143

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 144–145why, one step back
144 r = requests.get(url)
145 self.assertEqual(r.status_code, 200)

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 146why, one step back
146

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 147–150why, one step back
147 # reset auto authentication
148 requests.auth_manager.empty()149150

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 151why, one step back
151 def test_POSTBIN_GET_POST_FILES(self):

test for gzip decompressKenneth Reitzbefore adoption1359094

line 152why, one step back
152

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 153why, one step back
153 for service in SERVICES:

Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4

line 154why, one step back
154

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 155–156why, one step back
155 url = service('post')
156 post = requests.post(url).raise_for_status()

Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4

line 157why, one step back
157

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 158–159why, one step back
158 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 back
160

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 161–162why, one step back
161 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 back
163

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 164–167why, one step back
164 post3 = requests.post(url, data='[{"some": "json"}]')
165 self.assertEqual(post3.status_code, 200)166167

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 168why, one step back
168 def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):

test for gzip decompressKenneth Reitzbefore adoption1359094

line 169why, one step back
169

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 170why, one step back
170 for service in SERVICES:

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 171why, one step back
171

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 172–175why, one step back
172 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 back
176

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 177–179why, one step back
177 self.assertEqual(post.status_code, 200)
178179

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

lines 180–181why, one step back
180 def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):
181

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 182why, one step back
182 for service in SERVICES:

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 183why, one step back
183

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 184why, one step back
184 url = service('post')

Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94

line 185why, one step back
185

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 186–188why, one step back
186 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 back
189

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 190why, one step back
190 self.assertEqual(post2.status_code, 200)

Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94

line 191why, one step back
191

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 192why, one step back
192

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 193why, one step back
193 def test_nonzero_evaluation(self):

test for gzip decompressKenneth Reitzbefore adoption1359094

line 194why, one step back
194

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 195why, one step back
195 for service in SERVICES:

test for gzip decompressKenneth Reitzbefore adoption1359094

line 196why, one step back
196

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 197–198why, one step back
197 r = requests.get(service('status', '500'))
198 self.assertEqual(bool(r), False)

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 199why, one step back
199

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 200–203why, one step back
200 r = requests.get(service('/'))
201 self.assertEqual(bool(r), True)202203

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 204why, one step back
204 def test_request_ok_set(self):

test for gzip decompressKenneth Reitzbefore adoption1359094

line 205why, one step back
205

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 206why, one step back
206 for service in SERVICES:

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 207why, one step back
207

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 208–211why, one step back
208 r = requests.get(service('status', '404'))
209 self.assertEqual(r.ok, False)210211

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 212why, one step back
212 def test_status_raising(self):

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 213why, one step back
213 r = requests.get(httpbin('status', '404'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 214why, one step back
214 self.assertRaises(requests.HTTPError, r.raise_for_status)

test for gzip decompressKenneth Reitzbefore adoption1359094

line 215why, one step back
215

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 216why, one step back
216 r = requests.get(httpbin('status', '200'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

lines 217–218why, one step back
217 self.assertFalse(r.error)
218 r.raise_for_status()

test for gzip decompressKenneth Reitzbefore adoption1359094

line 219why, one step back
219

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 220why, one step back
220

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 221why, one step back
221 def test_cookie_jar(self):

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 222why, one step back
222

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

lines 223–224why, one step back
223 jar = cookielib.CookieJar()
224 self.assertFalse(jar)

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 225why, one step back
225

Porting cookie test to httpbin.org.Zbigniew Siciarzbefore adoption4d3a9de

lines 226–227why, one step back
226 url = httpbin('cookies', 'set', 'requests_cookie', 'awesome')
227 r = requests.get(url, cookies=jar)

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 228why, one step back
228 self.assertTrue(jar)

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 229why, one step back
229

Testing that cookies actually work.Zbigniew Siciarzbefore adoption54fd24b

lines 230–235why, one step back
230 cookie_found = False
231 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 back
236
237 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 back
239

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 240why, one step back
240

test for gzip decompressKenneth Reitzbefore adoption1359094

line 241why, one step back
241 def test_decompress_gzip(self):

whitespaceKenneth Reitzbefore adoption800b034

line 242why, one step back
242

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 243why, one step back
243 r = requests.get(httpbin('gzip'))

test for gzip decompressKenneth Reitzbefore adoption1359094

line 244why, one step back
244 r.content.decode('ascii')

add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9

line 245why, one step back
245

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 246why, one step back
246

add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9

lines 247–248why, one step back
247 def test_autoauth(self):
248

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

lines 249–250why, one step back
249 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 back
251

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 252why, one step back
252 r = requests.get(httpbin('basic-auth', 'user', 'pass'))

add autoauth tuple http basic testKenneth Reitzbefore adoptionf494cd9

line 253why, one step back
253 self.assertEquals(r.status_code, 200)

whitespaceKenneth Reitzbefore adoption800b034

line 254why, one step back
254

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 255why, one step back
255

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 256–261why, one step back
256 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)260261

test for unicode url issuesKenneth Reitzbefore adoption8a4a05a

line 262why, one step back
262 def test_unicode_get(self):

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 263why, one step back
263

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 264why, one step back
264 for service in SERVICES:

test for unicode url issuesKenneth Reitzbefore adoption8a4a05a

line 265why, one step back
265

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 266why, one step back
266 url = service('/')

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 267why, one step back
267

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 268–272why, one step back
268 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 back
273

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 274why, one step back
274

HTTP Basic recursion. Fixes #31Kenneth Reitzbefore adoption1421ffa

line 275why, one step back
275 def test_httpauth_recursion(self):

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 276why, one step back
276

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

line 277why, one step back
277 http_auth = ('user', 'BADpass')

HTTP Basic recursion. Fixes #31Kenneth Reitzbefore adoption1421ffa

line 278why, one step back
278

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 279–281why, one step back
279 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 back
282

WHITESPACEKenneth Reitzbefore adoption1fa1cdd

line 283why, one step back
283

Add tests for settingsJohannes Gorsetbefore adoption21e2d0c

line 284why, one step back
284 def test_settings(self):

Timeouts are normal errors now.Kenneth Reitzbefore adoption162b751

lines 285–289why, one step back
285
286 def test():287 r = requests.get(httpbin(''))288 r.raise_for_status()289

rackspace cloud's net connection is insaneKenneth Reitzbefore adoption74013d7

line 290why, one step back
290 with requests.settings(timeout=0.0000001):

Timeouts are normal errors now.Kenneth Reitzbefore adoption162b751

line 291why, one step back
291 self.assertRaises(requests.Timeout, test)

Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94

line 292why, one step back
292

Merge remote-tracking branch 'upstream/develop' into developZbigniew Siciarzbefore adoption1f12117

lines 293–294why, one step back
293 with requests.settings(timeout=100):
294 requests.get(httpbin(''))

whitespaceKenneth Reitzbefore adoptioncd0d0a2

line 295why, one step back
295

Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94

line 296why, one step back
296

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

lines 297–298why, one step back
297 def test_urlencoded_post_data(self):
298

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 299why, one step back
299 for service in SERVICES:

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

line 300why, one step back
300

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 301–312why, one step back
301 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'), '')311312

Add test for non-urlencoded post dataJohannes Gorsetbefore adoption637d033

line 313why, one step back
313 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 back
314

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 315why, one step back
315 for service in SERVICES:

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

line 316why, one step back
316

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 317–329why, one step back
317 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')328329

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

lines 330–331why, one step back
330 def test_urlencoded_post_querystring(self):
331

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 332why, one step back
332 for service in SERVICES:

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

line 333why, one step back
333

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 334–344why, one step back
334 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'), '')343344

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

lines 345–346why, one step back
345 def test_nonurlencoded_post_querystring(self):
346

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 347why, one step back
347 for service in SERVICES:

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

line 348why, one step back
348

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 349–359why, one step back
349 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'), '')358359

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

lines 360–361why, one step back
360 def test_urlencoded_post_query_and_data(self):
361

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 362why, one step back
362 for service in SERVICES:

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

line 363why, one step back
363

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 364–377why, one step back
364 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'), '')376377

Allow POST and PUT requests to take both querystring params and request bodyRichard Boultonbefore adoption80d860d

line 378why, one step back
378 def test_nonurlencoded_post_query_and_data(self):

Improved redirection behavior for 301/303Kenneth Reitzbefore adoptione153b94

line 379why, one step back
379

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 380why, one step back
380 for service in SERVICES:

whitespace!Kenneth Reitzbefore adoptiona987729

line 381why, one step back
381

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 382–394why, one step back
382 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')393394

Implemented idna (fixes #76).Jérémy Bethmontbefore adoption868cd3d

lines 395–396why, one step back
395 def test_idna(self):
396 r = requests.get(u'http://➡.ws/httpbin')

test fixKenneth Reitzbefore adoption074150f

line 397why, one step back
397 assert 'httpbin' in r.url

HTTP Basic recursion. Fixes #31Kenneth Reitzbefore adoption1421ffa

line 398why, one step back
398

whitespace!Kenneth Reitzbefore adoptiona987729

line 399why, one step back
399

Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190

lines 400–401why, one step back
400 def test_urlencoded_get_query_multivalued_param(self):
401

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 402why, one step back
402 for service in SERVICES:

whitespace!Kenneth Reitzbefore adoptiona987729

line 403why, one step back
403

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 404–408why, one step back
404 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'))407408

Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190

line 409why, one step back
409 def test_urlencoded_post_querystring_multivalued(self):

whitespace!Kenneth Reitzbefore adoptiona987729

line 410why, one step back
410

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 411why, one step back
411 for service in SERVICES:

Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190

line 412why, one step back
412

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 413–422why, one step back
413 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'), '')421422

Merge branch 'develop' of https://github.com/rabad/requests into developKenneth Reitzbefore adoption9b6a190

lines 423–424why, one step back
423 def test_urlencoded_post_query_multivalued_and_data(self):
424

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 425why, one step back
425 for service in SERVICES:

test for unicode url issuesKenneth Reitzbefore adoption8a4a05a

line 426why, one step back
426

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 427–439why, one step back
427 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'), '')438439

redirect history length testKenneth Reitzbefore adoption87560d6

lines 440–441why, one step back
440 def test_redirect_history(self):
441

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 442–448why, one step back
442 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)447448

test relative redirectsKenneth Reitzbefore adoptionb141da3

lines 449–456why, one step back
449 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)456

redirect history length testKenneth Reitzbefore adoption87560d6

line 457why, one step back
457

whitespaceKenneth Reitzbefore adoption800b034

line 458why, one step back
458if __name__ == '__main__':

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 459why, one step back
459 unittest.main()