Skip to content
Myr

test_requests.py

This file

Path

test_requests.py

475 lines · 12.8 KiB · Python

Last changed by

cleanupsKenneth Reitzbefore adoption9322d13

History of this file

Take it

The walk stopped after 200 commits: lines older than 3d1444b point at it.

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 1–7why, one step back
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-34from __future__ import with_statement56import unittest7import 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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 13–15why, one step back
13
14import requests15

cleanupsKenneth Reitzbefore adoption9322d13

line 16why, one step back
16from requests.sessions import Session

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

proper PATCH testingKenneth Reitzbefore adoption8c81cf6

lines 22–23why, one step back
22# HTTPBIN_URL = 'http://staging.httpbin.org/'
23# HTTPSBIN_URL = 'https://httpbin-staging.ep.io/'

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 24–34why, one step back
24
2526def httpbin(*suffix):27 """Returns url for HTTPBIN resource."""2829 return HTTPBIN_URL + '/'.join(suffix)303132def httpsbin(*suffix):33 """Returns url for HTTPSBIN resource."""34

Actually use the HTTPSBIN variable for test https requestsRichard Boultonbefore adoption4320f81

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 36–37why, one step back
36
37

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 39why, one step back
39

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 40–41why, one step back
40
41

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 42–114why, one step back
42class RequestsTestSuite(unittest.TestCase):
43 """Requests test cases."""444546 def setUp(self):47 pass484950 def tearDown(self):51 """Teardown."""52 pass535455 def test_invalid_url(self):56 self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')575859 def test_HTTP_200_OK_GET(self):60 r = requests.get(httpbin('/'))61 self.assertEqual(r.status_code, 200)626364 def test_HTTPS_200_OK_GET(self):65 r = requests.get(httpsbin('/'))66 self.assertEqual(r.status_code, 200)676869 def test_HTTP_200_OK_GET_WITH_PARAMS(self):70 heads = {'User-agent': 'Mozilla/5.0'}7172 r = requests.get(httpbin('user-agent'), headers=heads)7374 assert heads['User-agent'] in r.content75 self.assertEqual(r.status_code, 200)767778 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):79 heads = {'User-agent': 'Mozilla/5.0'}8081 r = requests.get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)82 self.assertEqual(r.status_code, 200)838485 def test_user_agent_transfers(self):86 """Issue XX"""8788 heads = {89 'User-agent':90 'Mozilla/5.0 (github.com/kennethreitz/requests)'91 }9293 r = requests.get(httpbin('user-agent'), headers=heads);94 self.assertTrue(heads['User-agent'] in r.content)9596 heads = {97 'user-agent':98 'Mozilla/5.0 (github.com/kennethreitz/requests)'99 }100101 r = requests.get(httpbin('user-agent'), headers=heads);102 self.assertTrue(heads['user-agent'] in r.content)103104105 def test_HTTP_200_OK_HEAD(self):106 r = requests.head(httpbin('/'))107 self.assertEqual(r.status_code, 200)108109110 def test_HTTPS_200_OK_HEAD(self):111 r = requests.head(httpsbin('/'))112 self.assertEqual(r.status_code, 200)113114

proper PATCH testingKenneth Reitzbefore adoption8c81cf6

lines 115–134why, one step back
115 def test_HTTP_200_OK_PUT(self):
116 r = requests.put(httpbin('put'))117 self.assertEqual(r.status_code, 200)118119120 def test_HTTPS_200_OK_PUT(self):121 r = requests.put(httpsbin('put'))122 self.assertEqual(r.status_code, 200)123124125 def test_HTTP_200_OK_PATCH(self):126 r = requests.patch(httpbin('patch'))127 self.assertEqual(r.status_code, 200)128129130 def test_HTTPS_200_OK_PATCH(self):131 r = requests.patch(httpsbin('patch'))132 self.assertEqual(r.status_code, 200)133134

cleanupsKenneth Reitzbefore adoption9322d13

line 135why, one step back
135 def test_AUTH_HTTP_200_OK_GET(self):

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 136why, one step back
136

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 138why, one step back
138

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 139–140why, one step back
139 auth = ('user', 'pass')
140 url = service('basic-auth', 'user', 'pass')

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 141why, one step back
141

cleanupsKenneth Reitzbefore adoption9322d13

lines 142–143why, one step back
142 r = requests.get(url, auth=auth)
143 # print r.__dict__

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 145why, one step back
145

cleanupsKenneth Reitzbefore adoption9322d13

line 146why, one step back
146

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 149why, one step back
149

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 150why, one step back
150

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 151–152why, one step back
151 def test_POSTBIN_GET_POST_FILES(self):
152

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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()

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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)

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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)

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 168–169why, one step back
168 def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):
169

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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'})

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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:

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 183why, one step back
183

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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'})

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 189why, one step back
189

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 191why, one step back
191

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 192why, one step back
192

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 193–194why, one step back
193 def test_nonzero_evaluation(self):
194

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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)

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 204–205why, one step back
204 def test_request_ok_set(self):
205

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 212–248why, one step back
212 def test_status_raising(self):
213 r = requests.get(httpbin('status', '404'))214 self.assertRaises(requests.HTTPError, r.raise_for_status)215216 r = requests.get(httpbin('status', '200'))217 self.assertFalse(r.error)218 r.raise_for_status()219220221 def test_cookie_jar(self):222223 jar = cookielib.CookieJar()224 self.assertFalse(jar)225226 url = httpbin('cookies', 'set', 'requests_cookie', 'awesome')227 r = requests.get(url, cookies=jar)228 self.assertTrue(jar)229230 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)236237 r = requests.get(httpbin('cookies'), cookies=jar)238 self.assertTrue('awesome' in r.content)239240241 def test_decompress_gzip(self):242243 r = requests.get(httpbin('gzip'))244 r.content.decode('ascii')245246247 def test_unicode_get(self):248

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 250why, one step back
250

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 252why, one step back
252

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 253–257why, one step back
253 requests.get(url, params={'foo': u'føø'})
254 requests.get(url, params={u'føø': u'føø'})255 requests.get(url, params={'føø': 'føø'})256 requests.get(url, params={'foo': u'foo'})257 requests.get(service('ø'), params={'foo': u'foo'})

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 258why, one step back
258

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 259why, one step back
259

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

http/https testsKenneth Reitzbefore adoptionbb16fe8

line 261why, one step back
261

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 262–263why, one step back
262 http_auth = ('user', 'BADpass')
263

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 264–266why, one step back
264 for service in SERVICES:
265 r = requests.get(service('basic-auth', 'user', 'pass'), auth=http_auth)266 self.assertEquals(r.status_code, 401)

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 267–269why, one step back
267
268269 def test_settings(self):

Timeouts are normal errors now.Kenneth Reitzbefore adoption162b751

lines 270–274why, one step back
270
271 def test():272 r = requests.get(httpbin(''))273 r.raise_for_status()274

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

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

Timeouts are normal errors now.Kenneth Reitzbefore adoption162b751

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 277–281why, one step back
277
278 with requests.settings(timeout=100):279 requests.get(httpbin(''))280281

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

lines 282–283why, one step back
282 def test_urlencoded_post_data(self):
283

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

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

line 285why, one step back
285

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 286–297why, one step back
286 r = requests.post(service('post'), data=dict(test='fooaowpeuf'))
287288 self.assertEquals(r.status_code, 200)289 self.assertEquals(r.headers['content-type'], 'application/json')290 self.assertEquals(r.url, service('post'))291292 rbody = json.loads(r.content)293294 self.assertEquals(rbody.get('form'), dict(test='fooaowpeuf'))295 self.assertEquals(rbody.get('data'), '')296297

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 298why, one step back
298 def test_nonurlencoded_post_data(self):

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

line 299why, one step back
299

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

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

line 301why, one step back
301

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 302–314why, one step back
302 r = requests.post(service('post'), data='fooaowpeuf')
303304 self.assertEquals(r.status_code, 200)305 self.assertEquals(r.headers['content-type'], 'application/json')306 self.assertEquals(r.url, service('post'))307308 rbody = json.loads(r.content)309 # Body wasn't valid url encoded data, so the server returns None as310 # "form" and the raw body as "data".311 self.assertEquals(rbody.get('form'), None)312 self.assertEquals(rbody.get('data'), 'fooaowpeuf')313314

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

lines 315–316why, one step back
315 def test_urlencoded_post_querystring(self):
316

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

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

line 318why, one step back
318

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 319–329why, one step back
319 r = requests.post(service('post'), params=dict(test='fooaowpeuf'))
320321 self.assertEquals(r.status_code, 200)322 self.assertEquals(r.headers['content-type'], 'application/json')323 self.assertEquals(r.url, service('post?test=fooaowpeuf'))324325 rbody = json.loads(r.content)326 self.assertEquals(rbody.get('form'), {}) # No form supplied327 self.assertEquals(rbody.get('data'), '')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_nonurlencoded_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='fooaowpeuf')
335336 self.assertEquals(r.status_code, 200)337 self.assertEquals(r.headers['content-type'], 'application/json')338 self.assertEquals(r.url, service('post?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_urlencoded_post_query_and_data(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–362why, one step back
349 r = requests.post(
350 service('post'),351 params=dict(test='fooaowpeuf'),352 data=dict(test2="foobar"))353354 self.assertEquals(r.status_code, 200)355 self.assertEquals(r.headers['content-type'], 'application/json')356 self.assertEquals(r.url, service('post?test=fooaowpeuf'))357358 rbody = json.loads(r.content)359 self.assertEquals(rbody.get('form'), dict(test2='foobar'))360 self.assertEquals(rbody.get('data'), '')361362

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

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 364why, one step back
364

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

whitespace!Kenneth Reitzbefore adoptiona987729

line 366why, one step back
366

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 367–379why, one step back
367 r = requests.post(service('post'),
368 params='fooaowpeuf', data="foobar")369370 self.assertEquals(r.status_code, 200)371 self.assertEquals(r.headers['content-type'], 'application/json')372 self.assertEquals(r.url, service('post?fooaowpeuf'))373374 rbody = json.loads(r.content)375376 self.assertEquals(rbody.get('form'), None)377 self.assertEquals(rbody.get('data'), 'foobar')378379

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

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

test fixKenneth Reitzbefore adoption074150f

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 383why, one step back
383

whitespace!Kenneth Reitzbefore adoptiona987729

line 384why, one step back
384

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

lines 385–386why, one step back
385 def test_urlencoded_get_query_multivalued_param(self):
386

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

whitespace!Kenneth Reitzbefore adoptiona987729

line 388why, one step back
388

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 389–393why, one step back
389 r = requests.get(service('get'), params=dict(test=['foo','baz']))
390 self.assertEquals(r.status_code, 200)391 self.assertEquals(r.url, service('get?test=foo&test=baz'))392393

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

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

whitespace!Kenneth Reitzbefore adoptiona987729

line 395why, one step back
395

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

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

line 397why, one step back
397

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 398–407why, one step back
398 r = requests.post(service('post'), params=dict(test=['foo','baz']))
399 self.assertEquals(r.status_code, 200)400 self.assertEquals(r.headers['content-type'], 'application/json')401 self.assertEquals(r.url, service('post?test=foo&test=baz'))402403 rbody = json.loads(r.content)404 self.assertEquals(rbody.get('form'), {}) # No form supplied405 self.assertEquals(rbody.get('data'), '')406407

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

lines 408–409why, one step back
408 def test_urlencoded_post_query_multivalued_and_data(self):
409

http/https testsKenneth Reitzbefore adoptionbb16fe8

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

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

line 411why, one step back
411

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 412–424why, one step back
412 r = requests.post(
413 service('post'),414 params=dict(test=['foo','baz']),415 data=dict(test2="foobar",test3=['foo','baz']))416417 self.assertEquals(r.status_code, 200)418 self.assertEquals(r.headers['content-type'], 'application/json')419 self.assertEquals(r.url, service('post?test=foo&test=baz'))420 rbody = json.loads(r.content)421 self.assertEquals(rbody.get('form'), dict(test2='foobar',test3='foo'))422 self.assertEquals(rbody.get('data'), '')423424

redirect history length testKenneth Reitzbefore adoption87560d6

lines 425–426why, one step back
425 def test_redirect_history(self):
426

http/https testsKenneth Reitzbefore adoptionbb16fe8

lines 427–433why, one step back
427 for service in SERVICES:
428429 r = requests.get(service('redirect', '3'))430 self.assertEquals(r.status_code, 200)431 self.assertEquals(len(r.history), 3)432433

test relative redirectsKenneth Reitzbefore adoptionb141da3

lines 434–441why, one step back
434 def test_relative_redirect_history(self):
435436 for service in SERVICES:437438 r = requests.get(service('relative-redirect', '3'))439 self.assertEquals(r.status_code, 200)440 self.assertEquals(len(r.history), 3)441

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

lines 442–443why, one step back
442
443 def test_session_HTTP_200_OK_GET(self):

cleanupsKenneth Reitzbefore adoption9322d13

line 444why, one step back
444

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

lines 445–448why, one step back
445 s = Session()
446 r = s.get(httpbin('/'))447 self.assertEqual(r.status_code, 200)448

cleanupsKenneth Reitzbefore adoption9322d13

line 449why, one step back
449

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

line 450why, one step back
450 def test_session_HTTPS_200_OK_GET(self):

cleanupsKenneth Reitzbefore adoption9322d13

line 451why, one step back
451

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

lines 452–455why, one step back
452 s = Session()
453 r = s.get(httpsbin('/'))454 self.assertEqual(r.status_code, 200)455

cleanupsKenneth Reitzbefore adoption9322d13

line 456why, one step back
456

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

line 457why, one step back
457 def test_session_persistent_headers(self):

cleanupsKenneth Reitzbefore adoption9322d13

line 458why, one step back
458

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

line 459why, one step back
459 heads = {'User-agent': 'Mozilla/5.0'}

cleanupsKenneth Reitzbefore adoption9322d13

line 460why, one step back
460

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

lines 461–463why, one step back
461 s = Session()
462 s.headers = heads463 # Make 2 requests from Session object, should send header both times

cleanupsKenneth Reitzbefore adoption9322d13

lines 464–465why, one step back
464 r1 = s.get(httpbin('user-agent'))
465

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

line 466why, one step back
466 assert heads['User-agent'] in r1.content

cleanupsKenneth Reitzbefore adoption9322d13

lines 467–468why, one step back
467 r2 = s.get(httpbin('user-agent'))
468

Merge branch 'feature/session' of https://github.com/tomhsx/requests into feature/sessionKenneth Reitzbefore adoption2fa0215

line 469why, one step back
469 assert heads['User-agent'] in r2.content

cleanupsKenneth Reitzbefore adoption9322d13

lines 470–472why, one step back
470 self.assertEqual(r2.status_code, 200)
471472

redirect history length testKenneth Reitzbefore adoption87560d6

line 473why, one step back
473

Update documentation of the "data" parameter for requests.post() to indicate that it allows bytes. Update documentation of requests.put() to refer to the "data" parameter rather than the (hidden, but functional) "params" parameter, and note that that also allows both bytes and dictionaries.Richard Boultonbefore adoption3d1444b

lines 474–475why, one step back
474if __name__ == '__main__':
475 unittest.main()