Skip to content
Myr

test_requests.py

This file

Path

test_requests.py

809 lines · 23.4 KiB · Python

Last changed by

binary data upload bug testKenneth Reitzbefore adoption0d8c08c

History of this file

Take it

The walk stopped after 200 commits: lines older than 4a3bee6 point at it.

documentation updateKenneth Reitzbefore adoption4a3bee6

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

blahKenneth Reitzbefore adoptionb0e2e4f

line 4why, one step back
4import io

oh snapKenneth Reitzbefore adoptione7bcc3b

line 5why, one step back
5import json

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

lines 6–7why, one step back
6import time
7import os

whateverKenneth Reitzbefore adoptione84a7c7

line 8why, one step back
8import sys

no more unittest2Kenneth Reitzbefore adoption3d54269

line 9why, one step back
9import unittest

documentation updateKenneth Reitzbefore adoption4a3bee6

line 10why, one step back
10

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

line 11why, one step back
11import requests

oh snapKenneth Reitzbefore adoptione7bcc3b

line 12why, one step back
12from requests.compat import str, bytes, StringIO

blahKenneth Reitzbefore adoptionb0e2e4f

line 13why, one step back
13# import envoy

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

line 14why, one step back
14from requests import HTTPError

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 15why, one step back
15from requests import get, post, head, put

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

line 16why, one step back
16from requests.auth import HTTPBasicAuth, HTTPDigestAuth

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 17why, one step back
17

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 18why, one step back
18

oh snapKenneth Reitzbefore adoptione7bcc3b

line 19why, one step back
19

whateverKenneth Reitzbefore adoptione84a7c7

lines 20–21why, one step back
20if (sys.platform == 'win32') and ('HTTPBIN_URL' not in os.environ):
21 os.environ['HTTPBIN_URL'] = 'http://httpbin.org/'

documentation updateKenneth Reitzbefore adoption4a3bee6

line 22why, one step back
22

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

lines 23–24why, one step back
23# TODO: Detect an open port.
24PORT = os.environ.get('HTTPBIN_PORT', '7077')

whateverKenneth Reitzbefore adoptione84a7c7

line 25why, one step back
25HTTPBIN_URL = os.environ.get('HTTPBIN_URL', 'http://0.0.0.0:%s/' % (PORT))

documentation updateKenneth Reitzbefore adoption4a3bee6

line 26why, one step back
26

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

lines 27–33why, one step back
27
28def httpbin(*suffix):29 """Returns url for HTTPBIN resource."""3031 return HTTPBIN_URL + '/'.join(suffix)3233

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 34why, one step back
34SERVICES = (httpbin, )

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 35why, one step back
35

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 36why, one step back
36_httpbin = False

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 37why, one step back
37

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 38why, one step back
38class TestSetup(object):

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 40why, one step back
40

Merge branch 'release/0.6.3'Kenneth Reitzbefore adoption1551158

lines 41–42why, one step back
41 # It goes to eleven.
42 _multiprocess_can_split_ = True

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 43why, one step back
43

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 44why, one step back
44 def setUp(self):

documentation updateKenneth Reitzbefore adoption4a3bee6

line 45why, one step back
45

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 46why, one step back
46 global _httpbin

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 47why, one step back
47

whateverKenneth Reitzbefore adoptione84a7c7

line 48why, one step back
48 if (not 'HTTPBIN_URL' in os.environ) and not _httpbin:

blahKenneth Reitzbefore adoptionb0e2e4f

lines 49–50why, one step back
49 # c = envoy.connect('httpbin %s' % (PORT))
50 # time.sleep(1)

whateverKenneth Reitzbefore adoptione84a7c7

line 51why, one step back
51 _httpbin = True

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

lines 52–53why, one step back
52
53

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

lines 54–55why, one step back
54class RequestsTestSuite(TestSetup, unittest.TestCase):
55 """Requests test cases."""

Merge branch '400-header_expand-unicode' of https://github.com/acdha/requests into developKenneth Reitzbefore adoption1b6f1b0

line 56why, one step back
56

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

line 57why, one step back
57 def test_entry_points(self):

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 58why, one step back
58

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

lines 59–67why, one step back
59 requests.session
60 requests.session().get61 requests.session().head62 requests.get63 requests.head64 requests.put65 requests.patch66 requests.post67

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

line 68why, one step back
68 def test_invalid_url(self):

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 69why, one step back
69 self.assertRaises(ValueError, get, 'hiwpefhipowhefopw')

documentation updateKenneth Reitzbefore adoption4a3bee6

line 70why, one step back
70

Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption5ca5b7e

lines 71–72why, one step back
71
72 def test_path_is_not_double_encoded(self):

Merge branch 'py3-uri-encoding' of https://github.com/mgiuca/requests into developKenneth Reitzbefore adoption9e2f5dd

line 73why, one step back
73 request = requests.Request("http://0.0.0.0/get/test case")

Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption5ca5b7e

line 74why, one step back
74

Merge branch 'py3-uri-encoding' of https://github.com/mgiuca/requests into developKenneth Reitzbefore adoption9e2f5dd

line 75why, one step back
75 assert request.path_url == "/get/test%20case"

Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption5ca5b7e

line 76why, one step back
76

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 78why, one step back
78 r = get(httpbin('/get'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

documentation updateKenneth Reitzbefore adoption4a3bee6

line 80why, one step back
80

Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d

line 81why, one step back
81 def test_response_sent(self):

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 82why, one step back
82 r = get(httpbin('/get'))

Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d

lines 83–85why, one step back
83
84 self.assertTrue(r.request.sent)85

Merge branch 'release/0.6.4'Kenneth Reitzbefore adoption4f6fc98

line 86why, one step back
86 def test_HTTP_302_ALLOW_REDIRECT_GET(self):

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 87why, one step back
87 r = get(httpbin('redirect', '1'))

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 89why, one step back
89

Merge branch 'release/0.6.4'Kenneth Reitzbefore adoption4f6fc98

line 90why, one step back
90 def test_HTTP_302_GET(self):

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 91why, one step back
91 r = get(httpbin('redirect', '1'), allow_redirects=False)

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

line 92why, one step back
92 self.assertEqual(r.status_code, 302)

Merge branch 'release/0.6.4'Kenneth Reitzbefore adoption4f6fc98

line 93why, one step back
93

documentation updateKenneth Reitzbefore adoption4a3bee6

line 94why, one step back
94

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

lines 95–96why, one step back
95 def test_HTTP_200_OK_GET_WITH_PARAMS(self):
96 heads = {'User-agent': 'Mozilla/5.0'}

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 97why, one step back
97

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 98why, one step back
98 r = get(httpbin('user-agent'), headers=heads)

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 99why, one step back
99

blahKenneth Reitzbefore adoptionb0e2e4f

line 100why, one step back
100 assert heads['User-agent'] in r.text

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

lines 101–102why, one step back
101 self.assertEqual(r.status_code, 200)
102

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 103why, one step back
103

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 107why, one step back
107 r = get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

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

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 109why, one step back
109

Merge branch '400-header_expand-unicode' of https://github.com/acdha/requests into developKenneth Reitzbefore adoption1b6f1b0

lines 110–113why, one step back
110 def test_unicode_headers(self):
111 # Simply calling requests with a unicode instance should simply work112 # when the characters are all representable using latin-1:113 heads = { u'User-Agent': u'Requests Test Suite' }

add failing test for unicode headers (python 2.x only)David Kemp (Work)before adoptionf478c34

line 114why, one step back
114 requests.get(url=httpbin('get'), headers=heads)

Merge branch 'py3-uri-encoding' of https://github.com/mgiuca/requests into developKenneth Reitzbefore adoption9e2f5dd

line 115why, one step back
115

Merge branch '400-header_expand-unicode' of https://github.com/acdha/requests into developKenneth Reitzbefore adoption1b6f1b0

lines 116–119why, one step back
116 # Characters outside latin-1 should raise an exception:
117 heads = { u'User-Agent': u'\u30cd\u30c3\u30c8\u30ef\u30fc\u30af' }118 self.assertRaises(UnicodeEncodeError, requests.get,119 url=httpbin('get'), headers=heads)

Merge branch 'py3-uri-encoding' of https://github.com/mgiuca/requests into developKenneth Reitzbefore adoption9e2f5dd

lines 120–162why, one step back
120
121 def test_session_with_escaped_url(self):122 # Test a URL that contains percent-escaped characters123 # This URL should not be modified (double-escaped)124 # Tests:125 # - Quoted illegal characters ("%20" (' '), "%3C" ('<'), "%3E" ('>'))126 # - Quoted reserved characters ("%25" ('%'), "%23" ('#'), "%2F" ('/'))127 # - Quoted non-ASCII characters ("%C3%98", "%C3%A5")128 path_fully_escaped = '%3Ca%25b%23c%2Fd%3E/%C3%98%20%C3%A5'129 url = httpbin('get/' + path_fully_escaped)130 response = get(url)131 self.assertEqual(response.url, httpbin('get/' + path_fully_escaped))132133 # Test that illegal characters in a path get properly percent-escaped134 # Tests:135 # - Bare illegal characters (space, '<')136 # - Bare non-ASCII characters ('\u00d8')137 path = u'<a%25b%23c%2Fd%3E/\u00d8 %C3%A5'138 url = httpbin('get/' + path)139 response = get(url)140 self.assertEqual(response.url, httpbin('get/' + path_fully_escaped))141142 # Test that reserved characters in a path do not get percent-escaped143 # Tests:144 # - All reserved characters (RFC 3986), except '?', '#', '[' and ']',145 # which are not allowed in the path, and ';' which delimits146 # parameters.147 # All such characters must be allowed bare in path, and must not be148 # encoded.149 # - Special unreserved characters (RFC 3986), which should not be150 # encoded (even though it wouldn't hurt).151 path_reserved = '!$&\'()*+,/:=@-._~'152 url = httpbin('get/' + path_reserved)153 response = get(url)154 self.assertEqual(response.url, httpbin('get/' + path_reserved))155156 # Test that percent-encoded unreserved characters in a path get157 # normalised to their un-encoded forms.158 path_unreserved = 'ABCDwxyz1234-._~'159 path_unreserved_escaped = '%41%42%43%44%77%78%79%7A%31%32%33%34%2D%2E%5F%7E'160 url = httpbin('get/' + path_unreserved_escaped)161 response = get(url)162 self.assertEqual(response.url, httpbin('get/' + path_unreserved))

add failing test for unicode headers (python 2.x only)David Kemp (Work)before adoptionf478c34

line 163why, one step back
163

Merge branch 'mgiuca-uri-cleanup-nonpath' into developKenneth Reitzbefore adoptionb887ea3

lines 164–186why, one step back
164 # Re-run all of the same tests on the query part of the URI
165 query_fully_escaped = '%3Ca%25b%23c%2Fd%3E=%C3%98%20%C3%A5'166 url = httpbin('get/?' + query_fully_escaped)167 response = get(url)168 self.assertEqual(response.url, httpbin('get/?' + query_fully_escaped))169170 query = u'<a%25b%23c%2Fd%3E=\u00d8 %C3%A5'171 url = httpbin('get/?' + query)172 response = get(url)173 self.assertEqual(response.url, httpbin('get/?' + query_fully_escaped))174175 # The legal characters in query happens to be the same as in path176 query_reserved = '!$&\'()*+,/:=@-._~'177 url = httpbin('get/?' + query_reserved)178 response = get(url)179 self.assertEqual(response.url, httpbin('get/?' + query_reserved))180181 query_unreserved = 'ABCDwxyz=1234-._~'182 query_unreserved_escaped = '%41%42%43%44%77%78%79%7A=%31%32%33%34%2D%2E%5F%7E'183 url = httpbin('get/?' + query_unreserved_escaped)184 response = get(url)185 self.assertEqual(response.url, httpbin('get/?' + query_unreserved))186

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 187why, one step back
187

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

lines 188–189why, one step back
188 def test_user_agent_transfers(self):
189 """Issue XX"""

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 190why, one step back
190

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

lines 191–194why, one step back
191 heads = {
192 'User-agent':193 'Mozilla/5.0 (github.com/kennethreitz/requests)'194 }

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 195why, one step back
195

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

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

blahKenneth Reitzbefore adoptionb0e2e4f

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 198why, one step back
198

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

lines 199–203why, one step back
199 heads = {
200 'user-agent':201 'Mozilla/5.0 (github.com/kennethreitz/requests)'202 }203

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

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

blahKenneth Reitzbefore adoptionb0e2e4f

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

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

line 206why, one step back
206

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 207why, one step back
207

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 209why, one step back
209 r = head(httpbin('/get'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

documentation updateKenneth Reitzbefore adoption4a3bee6

line 211why, one step back
211

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

lines 212–213why, one step back
212
213 def test_HTTP_200_OK_PUT(self):

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 214why, one step back
214 r = put(httpbin('put'))

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

lines 215–217why, one step back
215 self.assertEqual(r.status_code, 200)
216217

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

line 218why, one step back
218 def test_BASICAUTH_TUPLE_HTTP_200_OK_GET(self):

documentation updateKenneth Reitzbefore adoption4a3bee6

line 219why, one step back
219

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4

line 221why, one step back
221

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa

line 224why, one step back
224

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 225why, one step back
225 r = get(url, auth=auth)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa

line 227why, one step back
227

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 228why, one step back
228 r = get(url)

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

lines 229–232why, one step back
229 self.assertEqual(r.status_code, 401)
230231232 s = requests.session(auth=auth)

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 233why, one step back
233 r = get(url, session=s)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 234–235why, one step back
234 self.assertEqual(r.status_code, 200)
235

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

line 236why, one step back
236

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

lines 237–243why, one step back
237 def test_BASICAUTH_HTTP_200_OK_GET(self):
238239 for service in SERVICES:240241 auth = HTTPBasicAuth('user', 'pass')242 url = service('basic-auth', 'user', 'pass')243

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 244why, one step back
244 r = get(url, auth=auth)

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

lines 245–247why, one step back
245 self.assertEqual(r.status_code, 200)
246247 auth = ('user', 'pass')

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 248why, one step back
248 r = get(url, auth=auth)

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

lines 249–250why, one step back
249 self.assertEqual(r.status_code, 200)
250

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 251why, one step back
251 r = get(url)

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

lines 252–255why, one step back
252 self.assertEqual(r.status_code, 401)
253254255 s = requests.session(auth=auth)

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 256why, one step back
256 r = get(url, session=s)

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

lines 257–259why, one step back
257 self.assertEqual(r.status_code, 200)
258259

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

lines 260–263why, one step back
260 def test_DIGESTAUTH_HTTP_200_OK_GET(self):
261262 for service in SERVICES:263

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

line 264why, one step back
264 auth = HTTPDigestAuth('user', 'pass')

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

lines 265–266why, one step back
265 url = service('digest-auth', 'auth', 'user', 'pass')
266

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 267why, one step back
267 r = get(url, auth=auth)

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

lines 268–269why, one step back
268 self.assertEqual(r.status_code, 200)
269

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 270why, one step back
270 r = get(url)

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

lines 271–274why, one step back
271 self.assertEqual(r.status_code, 401)
272273274 s = requests.session(auth=auth)

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 275why, one step back
275 r = get(url, session=s)

Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05

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

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 277why, one step back
277

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 279why, one step back
279

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4

line 281why, one step back
281

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 283why, one step back
283 post1 = post(url).raise_for_status()

Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4

line 284why, one step back
284

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

lines 285–286why, one step back
285 post1 = post(url, data={'some': 'data'})
286 self.assertEqual(post1.status_code, 200)

Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17

line 287why, one step back
287

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 288why, one step back
288 post2 = post(url, files={'some': open('test_requests.py')})

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

line 290why, one step back
290

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 291why, one step back
291 post3 = post(url, data='[{"some": "json"}]')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 292–294why, one step back
292 self.assertEqual(post3.status_code, 200)
293294

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 296why, one step back
296

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 298why, one step back
298

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

lines 300–302why, one step back
300 post1 = post(url,
301 files={'some': open('test_requests.py')},302 data={'some': 'data'})

Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e

line 303why, one step back
303

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 304why, one step back
304 self.assertEqual(post1.status_code, 200)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 305–306why, one step back
305
306

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

lines 307–308why, one step back
307 def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):
308

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073

line 310why, one step back
310

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

line 312why, one step back
312

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 313why, one step back
313 post2 = post(url,

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 314–315why, one step back
314 files={'some': open('test_requests.py')},
315 headers = {'User-Agent': 'requests-tests'})

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 316why, one step back
316

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

line 318why, one step back
318

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 319why, one step back
319

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 321why, one step back
321

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 323why, one step back
323

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 324why, one step back
324 r = get(service('status', '500'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 325why, one step back
325 self.assertEqual(bool(r), False)

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 326why, one step back
326

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 327why, one step back
327 r = get(service('/get'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 328–330why, one step back
328 self.assertEqual(bool(r), True)
329330

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 332why, one step back
332

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 334why, one step back
334

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 335why, one step back
335 r = get(service('status', '404'))

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 336–337why, one step back
336 # print r.status_code
337 # r.raise_for_status()

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 338–340why, one step back
338 self.assertEqual(r.ok, False)
339340

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 342why, one step back
342 r = get(httpbin('status', '404'))

Merge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8

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

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 344why, one step back
344

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 345why, one step back
345 r = get(httpbin('status', '200'))

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

lines 346–347why, one step back
346 self.assertFalse(r.error)
347 r.raise_for_status()

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

line 348why, one step back
348

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 349why, one step back
349

Merge pull request #333 from bryanhelmig/developKenneth Reitzbefore adoption281e059

lines 350–353why, one step back
350 def test_default_status_raising(self):
351 config = {'danger_mode': True}352 args = [httpbin('status', '404')]353 kwargs = dict(config=config)

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 354why, one step back
354 self.assertRaises(HTTPError, get, *args, **kwargs)

Merge pull request #333 from bryanhelmig/developKenneth Reitzbefore adoption281e059

line 355why, one step back
355

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 356why, one step back
356 r = get(httpbin('status', '200'))

Merge pull request #333 from bryanhelmig/developKenneth Reitzbefore adoption281e059

lines 357–359why, one step back
357 self.assertEqual(r.status_code, 200)
358359

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

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

documentation updateKenneth Reitzbefore adoption4a3bee6

line 361why, one step back
361

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 362why, one step back
362 r = get(httpbin('gzip'))

Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667

lines 363–364why, one step back
363 r.content.decode('ascii')
364

Merge pull request #368 from jgorset/unicode-response-urlKenneth Reitzbefore adoption99f6581

lines 365–370why, one step back
365 def test_response_has_unicode_url(self):
366367 for service in SERVICES:368369 url = service('get')370

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 371why, one step back
371 response = get(url)

Merge pull request #368 from jgorset/unicode-response-urlKenneth Reitzbefore adoption99f6581

line 372why, one step back
372

assert isinstanceKenneth Reitzbefore adoption57ba337

line 373why, one step back
373 assert isinstance(response.url, str)

Merge pull request #368 from jgorset/unicode-response-urlKenneth Reitzbefore adoption99f6581

line 374why, one step back
374

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 375why, one step back
375

Merge branch 'release/0.3.3'Kenneth Reitzbefore adoption7215452

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

Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17

line 377why, one step back
377

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 379why, one step back
379

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 381why, one step back
381

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

lines 382–386why, one step back
382 get(url, params={'foo': 'føø'})
383 get(url, params={'føø': 'føø'})384 get(url, params={'føø': 'føø'})385 get(url, params={'foo': 'foo'})386 get(service('ø'), params={'foo': 'foo'})

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 387why, one step back
387

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 388why, one step back
388

Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17

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

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 390why, one step back
390

Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02

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

Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17

line 392why, one step back
392

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 394why, one step back
394 r = get(service('basic-auth', 'user', 'pass'), auth=http_auth)

blahKenneth Reitzbefore adoptionb0e2e4f

line 395why, one step back
395 self.assertEqual(r.status_code, 401)

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

line 396why, one step back
396

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

lines 397–399why, one step back
397
398 def test_urlencoded_post_data(self):399

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 401why, one step back
401

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 402why, one step back
402 r = post(service('post'), data=dict(test='fooaowpeuf'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 403why, one step back
403

blahKenneth Reitzbefore adoptionb0e2e4f

lines 404–406why, one step back
404 self.assertEqual(r.status_code, 200)
405 self.assertEqual(r.headers['content-type'], 'application/json')406 self.assertEqual(r.url, service('post'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 407why, one step back
407

blahKenneth Reitzbefore adoptionb0e2e4f

line 408why, one step back
408 rbody = json.loads(r.text)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 409why, one step back
409

blahKenneth Reitzbefore adoptionb0e2e4f

lines 410–411why, one step back
410 self.assertEqual(rbody.get('form'), dict(test='fooaowpeuf'))
411 self.assertEqual(rbody.get('data'), '')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 412–413why, one step back
412
413

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 415why, one step back
415

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 417why, one step back
417

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 418why, one step back
418 r = post(service('post'), data='fooaowpeuf')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 419why, one step back
419

blahKenneth Reitzbefore adoptionb0e2e4f

lines 420–422why, one step back
420 self.assertEqual(r.status_code, 200)
421 self.assertEqual(r.headers['content-type'], 'application/json')422 self.assertEqual(r.url, service('post'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 423why, one step back
423

blahKenneth Reitzbefore adoptionb0e2e4f

line 424why, one step back
424 rbody = json.loads(r.text)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 425–426why, one step back
425 # Body wasn't valid url encoded data, so the server returns None as
426 # "form" and the raw body as "data".

oh snapKenneth Reitzbefore adoptione7bcc3b

lines 427–428why, one step back
427
428 assert rbody.get('form') in (None, {})

blahKenneth Reitzbefore adoptionb0e2e4f

line 429why, one step back
429 self.assertEqual(rbody.get('data'), 'fooaowpeuf')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 430–431why, one step back
430
431

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

lines 432–433why, one step back
432 def test_urlencoded_post_querystring(self):
433

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 435why, one step back
435

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 436why, one step back
436 r = post(service('post'), params=dict(test='fooaowpeuf'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 437why, one step back
437

blahKenneth Reitzbefore adoptionb0e2e4f

lines 438–440why, one step back
438 self.assertEqual(r.status_code, 200)
439 self.assertEqual(r.headers['content-type'], 'application/json')440 self.assertEqual(r.url, service('post?test=fooaowpeuf'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 441why, one step back
441

blahKenneth Reitzbefore adoptionb0e2e4f

lines 442–444why, one step back
442 rbody = json.loads(r.text)
443 self.assertEqual(rbody.get('form'), {}) # No form supplied444 self.assertEqual(rbody.get('data'), '')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 445–446why, one step back
445
446

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

lines 447–448why, one step back
447 def test_urlencoded_post_query_and_data(self):
448

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7

line 450why, one step back
450

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 451why, one step back
451 r = post(

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 452–455why, one step back
452 service('post'),
453 params=dict(test='fooaowpeuf'),454 data=dict(test2="foobar"))455

blahKenneth Reitzbefore adoptionb0e2e4f

lines 456–458why, one step back
456 self.assertEqual(r.status_code, 200)
457 self.assertEqual(r.headers['content-type'], 'application/json')458 self.assertEqual(r.url, service('post?test=fooaowpeuf'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 459why, one step back
459

blahKenneth Reitzbefore adoptionb0e2e4f

lines 460–462why, one step back
460 rbody = json.loads(r.text)
461 self.assertEqual(rbody.get('form'), dict(test2='foobar'))462 self.assertEqual(rbody.get('data'), '')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 463–464why, one step back
463
464

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

line 465why, one step back
465 def test_nonurlencoded_postdata(self):

Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea

line 466why, one step back
466

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 467–468why, one step back
467 for service in SERVICES:
468

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 469why, one step back
469 r = post(service('post'), data="foobar")

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 470why, one step back
470

blahKenneth Reitzbefore adoptionb0e2e4f

lines 471–472why, one step back
471 self.assertEqual(r.status_code, 200)
472 self.assertEqual(r.headers['content-type'], 'application/json')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 473why, one step back
473

blahKenneth Reitzbefore adoptionb0e2e4f

line 474why, one step back
474 rbody = json.loads(r.text)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 475why, one step back
475

oh snapKenneth Reitzbefore adoptione7bcc3b

line 476why, one step back
476 assert rbody.get('form') in (None, {})

blahKenneth Reitzbefore adoptionb0e2e4f

line 477why, one step back
477 self.assertEqual(rbody.get('data'), 'foobar')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 478–479why, one step back
478
479

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 480why, one step back
480 # def test_idna(self):

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 481why, one step back
481 # r = get(u'http://➡.ws/httpbin')

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

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

Merge branch 'release/0.3.3'Kenneth Reitzbefore adoption7215452

line 483why, one step back
483

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 484why, one step back
484

Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc

lines 485–486why, one step back
485 def test_urlencoded_get_query_multivalued_param(self):
486

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 487–488why, one step back
487 for service in SERVICES:
488

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 489why, one step back
489 r = get(service('get'), params=dict(test=['foo','baz']))

blahKenneth Reitzbefore adoptionb0e2e4f

lines 490–491why, one step back
490 self.assertEqual(r.status_code, 200)
491 self.assertEqual(r.url, service('get?test=foo&test=baz'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 492–493why, one step back
492
493

Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc

lines 494–495why, one step back
494 def test_urlencoded_post_querystring_multivalued(self):
495

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 496–497why, one step back
496 for service in SERVICES:
497

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 498why, one step back
498 r = post(service('post'), params=dict(test=['foo','baz']))

blahKenneth Reitzbefore adoptionb0e2e4f

lines 499–501why, one step back
499 self.assertEqual(r.status_code, 200)
500 self.assertEqual(r.headers['content-type'], 'application/json')501 self.assertEqual(r.url, service('post?test=foo&test=baz'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 502why, one step back
502

blahKenneth Reitzbefore adoptionb0e2e4f

lines 503–505why, one step back
503 rbody = json.loads(r.text)
504 self.assertEqual(rbody.get('form'), {}) # No form supplied505 self.assertEqual(rbody.get('data'), '')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 506–507why, one step back
506
507

Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc

lines 508–509why, one step back
508 def test_urlencoded_post_query_multivalued_and_data(self):
509

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

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

Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc

line 511why, one step back
511

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 512why, one step back
512 r = post(

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 513–516why, one step back
513 service('post'),
514 params=dict(test=['foo','baz']),515 data=dict(test2="foobar",test3=['foo','baz']))516

blahKenneth Reitzbefore adoptionb0e2e4f

lines 517–519why, one step back
517 self.assertEqual(r.status_code, 200)
518 self.assertEqual(r.headers['content-type'], 'application/json')519 self.assertEqual(r.url, service('post?test=foo&test=baz'))

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 520why, one step back
520

blahKenneth Reitzbefore adoptionb0e2e4f

lines 521–522why, one step back
521 # print(r.text)
522 # print('-----------------------')

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 523why, one step back
523

blahKenneth Reitzbefore adoptionb0e2e4f

lines 524–528why, one step back
524 rbody = json.loads(r.text)
525 self.assertEqual(rbody.get('form'), dict(test2='foobar',test3=['foo','baz']))526 self.assertEqual(rbody.get('data'), '')527528

Merge branch 'redirect-no-follow' of https://github.com/millerdev/requestsKenneth Reitzbefore adoption98c719f

lines 529–532why, one step back
529 def test_GET_no_redirect(self):
530531 for service in SERVICES:532

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 533why, one step back
533 r = get(service('redirect', '3'), allow_redirects=False)

blahKenneth Reitzbefore adoptionb0e2e4f

lines 534–535why, one step back
534 self.assertEqual(r.status_code, 302)
535 self.assertEqual(len(r.history), 0)

Merge branch 'redirect-no-follow' of https://github.com/millerdev/requestsKenneth Reitzbefore adoption98c719f

lines 536–541why, one step back
536
537538 def test_HEAD_no_redirect(self):539540 for service in SERVICES:541

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 542why, one step back
542 r = head(service('redirect', '3'), allow_redirects=False)

blahKenneth Reitzbefore adoptionb0e2e4f

lines 543–544why, one step back
543 self.assertEqual(r.status_code, 302)
544 self.assertEqual(len(r.history), 0)

Merge branch 'redirect-no-follow' of https://github.com/millerdev/requestsKenneth Reitzbefore adoption98c719f

lines 545–546why, one step back
545
546

Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc

lines 547–548why, one step back
547 def test_redirect_history(self):
548

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 549–550why, one step back
549 for service in SERVICES:
550

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 551why, one step back
551 r = get(service('redirect', '3'))

blahKenneth Reitzbefore adoptionb0e2e4f

lines 552–553why, one step back
552 self.assertEqual(r.status_code, 200)
553 self.assertEqual(len(r.history), 3)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 554–559why, one step back
554
555556 def test_relative_redirect_history(self):557558 for service in SERVICES:559

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 560why, one step back
560 r = get(service('relative-redirect', '3'))

blahKenneth Reitzbefore adoptionb0e2e4f

lines 561–562why, one step back
561 self.assertEqual(r.status_code, 200)
562 self.assertEqual(len(r.history), 3)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 563–566why, one step back
563
564565 def test_session_HTTP_200_OK_GET(self):566

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

line 567why, one step back
567 s = requests.session()

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 568why, one step back
568 r = get(httpbin('/get'), session=s)

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 569–575why, one step back
569 self.assertEqual(r.status_code, 200)
570571572 def test_session_persistent_headers(self):573574 heads = {'User-agent': 'Mozilla/5.0'}575

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

line 576why, one step back
576 s = requests.session()

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 577why, one step back
577 s.headers = heads

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 578why, one step back
578

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 579why, one step back
579 # Make 2 requests from Session object, should send header both times

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 580why, one step back
580 r1 = get(httpbin('user-agent'), session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

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

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

line 582why, one step back
582

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 583why, one step back
583 r2 = get(httpbin('user-agent'), session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

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

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

lines 585–586why, one step back
585
586 new_heads = {'User-agent': 'blah'}

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 587why, one step back
587 r3 = get(httpbin('user-agent'), headers=new_heads, session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 588why, one step back
588 assert new_heads['User-agent'] in r3.text

Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb

line 589why, one step back
589

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

lines 590–591why, one step back
590 self.assertEqual(r2.status_code, 200)
591

Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52

lines 592–606why, one step back
592 def test_single_hook(self):
593594 def add_foo_header(args):595 if not args.get('headers'):596 args['headers'] = {}597598 args['headers'].update({599 'X-Foo': 'foo'600 })601602 return args603604 for service in SERVICES:605 url = service('headers')606

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 607why, one step back
607 response = get(

Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52

lines 608–613why, one step back
608 url = url,
609 hooks = {610 'args': add_foo_header611 }612 )613

blahKenneth Reitzbefore adoptionb0e2e4f

line 614why, one step back
614 assert 'foo' in response.text

Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52

lines 615–640why, one step back
615
616 def test_multiple_hooks(self):617618 def add_foo_header(args):619 if not args.get('headers'):620 args['headers'] = {}621622 args['headers'].update({623 'X-Foo': 'foo'624 })625626 return args627628 def add_bar_header(args):629 if not args.get('headers'):630 args['headers'] = {}631632 args['headers'].update({633 'X-Bar': 'bar'634 })635636 return args637638 for service in SERVICES:639 url = service('headers')640

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 641why, one step back
641 response = get(

Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52

lines 642–647why, one step back
642 url = url,
643 hooks = {644 'args': [add_foo_header, add_bar_header]645 }646 )647

blahKenneth Reitzbefore adoptionb0e2e4f

lines 648–649why, one step back
648 assert 'foo' in response.text
649 assert 'bar' in response.text

Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52

line 650why, one step back
650

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

line 651why, one step back
651 def test_session_persistent_cookies(self):

Merge branch 'release/0.3.3'Kenneth Reitzbefore adoption7215452

line 652why, one step back
652

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 653–656why, one step back
653 s = requests.session()
654655 # Internally dispatched cookies are sent.656 _c = {'kenneth': 'reitz', 'bessie': 'monke'}

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

lines 657–658why, one step back
657 r = get(httpbin('cookies'), cookies=_c, session=s)
658 r = get(httpbin('cookies'), session=s)

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 659–660why, one step back
659
660 # Those cookies persist transparently.

blahKenneth Reitzbefore adoptionb0e2e4f

line 661why, one step back
661 c = json.loads(r.text).get('cookies')

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 662–664why, one step back
662 assert c == _c
663664 # Double check.

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 665why, one step back
665 r = get(httpbin('cookies'), cookies={}, session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 666why, one step back
666 c = json.loads(r.text).get('cookies')

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 667–669why, one step back
667 assert c == _c
668669 # Remove a cookie by setting it's value to None.

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 670why, one step back
670 r = get(httpbin('cookies'), cookies={'bessie': None}, session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 671why, one step back
671 c = json.loads(r.text).get('cookies')

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 672–676why, one step back
672 del _c['bessie']
673 assert c == _c674675 # Test session-level cookies.676 s = requests.session(cookies=_c)

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 677why, one step back
677 r = get(httpbin('cookies'), session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 678why, one step back
678 c = json.loads(r.text).get('cookies')

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 679–681why, one step back
679 assert c == _c
680681 # Have the server set a cookie.

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 682why, one step back
682 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True, session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 683why, one step back
683 c = json.loads(r.text).get('cookies')

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 684–687why, one step back
684
685 assert 'k' in c686687 # And server-set cookie persistience.

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 688why, one step back
688 r = get(httpbin('cookies'), session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 689why, one step back
689 c = json.loads(r.text).get('cookies')

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 690–694why, one step back
690
691 assert 'k' in c692693694

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

lines 695–698why, one step back
695 def test_session_persistent_params(self):
696697 params = {'a': 'a_test'}698

Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de

line 699why, one step back
699 s = requests.session()

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

lines 700–702why, one step back
700 s.params = params
701702 # Make 2 requests from Session object, should send header both times

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 703why, one step back
703 r1 = get(httpbin('get'), session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

line 704why, one step back
704 assert params['a'] in r1.text

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

lines 705–708why, one step back
705
706707 params2 = {'b': 'b_test'}708

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 709why, one step back
709 r2 = get(httpbin('get'), params=params2, session=s)

blahKenneth Reitzbefore adoptionb0e2e4f

lines 710–711why, one step back
710 assert params['a'] in r2.text
711 assert params2['b'] in r2.text

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

lines 712–715why, one step back
712
713714 params3 = {'b': 'b_test', 'a': None, 'c': 'c_test'}715

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 716why, one step back
716 r3 = get(httpbin('get'), params=params3, session=s)

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

line 717why, one step back
717

blahKenneth Reitzbefore adoptionb0e2e4f

lines 718–720why, one step back
718 assert not params['a'] in r3.text
719 assert params3['b'] in r3.text720 assert params3['c'] in r3.text

Merge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8

lines 721–722why, one step back
721
722 def test_invalid_content(self):

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 723–726why, one step back
723 # WARNING: if you're using a terrible DNS provider (comcast),
724 # this will fail.725 try:726 hah = 'http://somedomainthatclearlydoesntexistg.com'

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 727why, one step back
727 r = get(hah, allow_redirects=False)

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 728–731why, one step back
728 except requests.ConnectionError:
729 pass # \o/730 else:731 assert False

Merge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8

line 732why, one step back
732

Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09

lines 733–734why, one step back
733
734 config = {'safe_mode': True}

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 735why, one step back
735 r = get(hah, allow_redirects=False, config=config)

Merge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8

line 736why, one step back
736 assert r.content == None

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

line 737why, one step back
737

Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d

lines 738–739why, one step back
738 def test_cached_response(self):
739

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 740why, one step back
740 r1 = get(httpbin('get'), prefetch=False)

blahKenneth Reitzbefore adoptionb0e2e4f

line 741why, one step back
741 assert not r1._content

Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d

line 742why, one step back
742 assert r1.content

blahKenneth Reitzbefore adoptionb0e2e4f

line 743why, one step back
743 assert r1.text

Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d

line 744why, one step back
744

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 745why, one step back
745 r2 = get(httpbin('get'), prefetch=True)

Merge branch 'develop'Kenneth Reitzbefore adoption19a2a6c

line 746why, one step back
746 assert r2._content

Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d

line 747why, one step back
747 assert r2.content

blahKenneth Reitzbefore adoptionb0e2e4f

line 748why, one step back
748 assert r2.text

Merge branch 'develop'Kenneth Reitzbefore adoption19a2a6c

lines 749–754why, one step back
749
750 def test_iter_lines(self):751752 lines = (0, 2, 10, 100)753754 for i in lines:

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 755why, one step back
755 r = get(httpbin('stream', str(i)), prefetch=False)

Merge branch 'streaming' of https://github.com/RonnyPfannschmidt/requests into developKenneth Reitzbefore adoptionf3ba022

lines 756–757why, one step back
756 lines = list(r.iter_lines())
757 len_lines = len(lines)

Merge branch 'develop'Kenneth Reitzbefore adoption19a2a6c

lines 758–759why, one step back
758
759 self.assertEqual(i, len_lines)

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

lines 760–768why, one step back
760
761 # Test 'dangling' fragment in responses that do not terminate in762 # a newline.763 quote = (764 '''Why will he not upon our fair request\n'''765 '''Untent his person and share the air with us?'''766 )767768 # Make a request and monkey-patch its contents

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 769why, one step back
769 r = get(httpbin('get'))

oh snapKenneth Reitzbefore adoptione7bcc3b

line 770why, one step back
770 r.raw = StringIO(quote)

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

lines 771–781why, one step back
771
772 # Make sure iter_lines doesn't chop the trailing bit773 lines = '\n'.join(r.iter_lines())774 self.assertEqual(lines, quote)775776 def test_safe_mode(self):777778 safe = requests.session(config=dict(safe_mode=True))779780 # Safe mode creates empty responses for failed requests.781 # Iterating on these responses should produce empty sequences

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 782why, one step back
782 r = get('http://_/', session=safe)

blahKenneth Reitzbefore adoptionb0e2e4f

line 783why, one step back
783 self.assertEqual(list(r.iter_lines()), [])

assert isinstanceKenneth Reitzbefore adoption57ba337

line 784why, one step back
784 assert isinstance(r.error, requests.exceptions.ConnectionError)

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

line 785why, one step back
785

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 786why, one step back
786 r = get('http://_/', session=safe)

blahKenneth Reitzbefore adoptionb0e2e4f

line 787why, one step back
787 self.assertEqual(list(r.iter_content()), [])

assert isinstanceKenneth Reitzbefore adoptionc4eb930

line 788why, one step back
788 assert isinstance(r.error, requests.exceptions.ConnectionError)

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

lines 789–790why, one step back
789
790 # When not in safe mode, should raise Timeout exception

fix 26Kenneth Reitzbefore adoption4493acc

lines 791–792why, one step back
791 self.assertRaises(
792 requests.exceptions.Timeout,

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 793why, one step back
793 get,

fix 26Kenneth Reitzbefore adoption4493acc

line 794why, one step back
794 httpbin('stream', '1000'), timeout=0.0001)

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

lines 795–796why, one step back
795
796 # In safe mode, should return a blank response

Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60

line 797why, one step back
797 r = get(httpbin('stream', '1000'), timeout=0.0001,

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

line 798why, one step back
798 config=dict(safe_mode=True))

dammit, i changed againKenneth Reitzbefore adoptiona939423

line 799why, one step back
799 assert r.content is None

assert isinstanceKenneth Reitzbefore adoptionc4eb930

line 800why, one step back
800 assert isinstance(r.error, requests.exceptions.Timeout)

binary data upload bug testKenneth Reitzbefore adoption0d8c08c

lines 801–805why, one step back
801
802 def test_upload_binary_data(self):803804 r = requests.get(httpbin('post'), auth=('a', 'b'), data='\xff')805

Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304

line 806why, one step back
806

Merge branch 'develop'Kenneth Reitzbefore adoption23efd56

line 807why, one step back
807

documentation updateKenneth Reitzbefore adoption4a3bee6

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

Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f

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