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 fileTake it
The walk stopped after 200 commits: lines older than 4a3bee6 point at it.
documentation updateKenneth Reitzbefore adoption4a3bee6
lines 1–3why, one step back1#!/usr/bin/env python2# -*- coding: utf-8 -*-3blahKenneth Reitzbefore adoptionb0e2e4f
line 4why, one step back4import iooh snapKenneth Reitzbefore adoptione7bcc3b
line 5why, one step back5import jsonMerge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
lines 6–7why, one step back6import time7import oswhateverKenneth Reitzbefore adoptione84a7c7
line 8why, one step back8import sysno more unittest2Kenneth Reitzbefore adoption3d54269
line 9why, one step back9import unittestdocumentation updateKenneth Reitzbefore adoption4a3bee6
line 10why, one step back10Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 11why, one step back11import requestsoh snapKenneth Reitzbefore adoptione7bcc3b
line 12why, one step back12from requests.compat import str, bytes, StringIOblahKenneth Reitzbefore adoptionb0e2e4f
line 13why, one step back13# import envoyMerge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
line 14why, one step back14from requests import HTTPErrorStandard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 15why, one step back15from requests import get, post, head, putMerge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
line 16why, one step back16from requests.auth import HTTPBasicAuth, HTTPDigestAuthMerge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 17why, one step back17Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 18why, one step back18oh snapKenneth Reitzbefore adoptione7bcc3b
line 19why, one step back19whateverKenneth Reitzbefore adoptione84a7c7
lines 20–21why, one step back20if (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 back22Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
lines 23–24why, one step back23# TODO: Detect an open port.24PORT = os.environ.get('HTTPBIN_PORT', '7077')whateverKenneth Reitzbefore adoptione84a7c7
line 25why, one step back25HTTPBIN_URL = os.environ.get('HTTPBIN_URL', 'http://0.0.0.0:%s/' % (PORT))documentation updateKenneth Reitzbefore adoption4a3bee6
line 26why, one step back26Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
lines 27–33why, one step back2728def httpbin(*suffix):29 """Returns url for HTTPBIN resource."""3031 return HTTPBIN_URL + '/'.join(suffix)3233Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 34why, one step back34SERVICES = (httpbin, )Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 35why, one step back35Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 36why, one step back36_httpbin = FalseMerge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 37why, one step back37Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 38why, one step back38class TestSetup(object):Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 39why, one step back39 """Requests test cases."""Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 40why, one step back40Merge branch 'release/0.6.3'Kenneth Reitzbefore adoption1551158
lines 41–42why, one step back41 # It goes to eleven.42 _multiprocess_can_split_ = TrueMerge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 43why, one step back43Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 44why, one step back44 def setUp(self):documentation updateKenneth Reitzbefore adoption4a3bee6
line 45why, one step back45Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 46why, one step back46 global _httpbinMerge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 47why, one step back47whateverKenneth Reitzbefore adoptione84a7c7
line 48why, one step back48 if (not 'HTTPBIN_URL' in os.environ) and not _httpbin:blahKenneth Reitzbefore adoptionb0e2e4f
lines 49–50why, one step back49 # c = envoy.connect('httpbin %s' % (PORT))50 # time.sleep(1)whateverKenneth Reitzbefore adoptione84a7c7
line 51why, one step back51 _httpbin = TrueMerge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
lines 52–53why, one step back5253Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
lines 54–55why, one step back54class 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 back56Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 57why, one step back57 def test_entry_points(self):Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 58why, one step back58Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
lines 59–67why, one step back59 requests.session60 requests.session().get61 requests.session().head62 requests.get63 requests.head64 requests.put65 requests.patch66 requests.post67Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 68why, one step back68 def test_invalid_url(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 69why, one step back69 self.assertRaises(ValueError, get, 'hiwpefhipowhefopw')documentation updateKenneth Reitzbefore adoption4a3bee6
line 70why, one step back70Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption5ca5b7e
lines 71–72why, one step back7172 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 back73 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 back74Merge branch 'py3-uri-encoding' of https://github.com/mgiuca/requests into developKenneth Reitzbefore adoption9e2f5dd
line 75why, one step back75 assert request.path_url == "/get/test%20case"Merge remote-tracking branch 'origin/develop' into developKenneth Reitzbefore adoption5ca5b7e
line 76why, one step back76Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 77why, one step back77 def test_HTTP_200_OK_GET(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 78why, one step back78 r = get(httpbin('/get'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 79why, one step back79 self.assertEqual(r.status_code, 200)documentation updateKenneth Reitzbefore adoption4a3bee6
line 80why, one step back80Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d
line 81why, one step back81 def test_response_sent(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 82why, one step back82 r = get(httpbin('/get'))Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d
lines 83–85why, one step back8384 self.assertTrue(r.request.sent)85Merge branch 'release/0.6.4'Kenneth Reitzbefore adoption4f6fc98
line 86why, one step back86 def test_HTTP_302_ALLOW_REDIRECT_GET(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 87why, one step back87 r = get(httpbin('redirect', '1'))Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 88why, one step back88 self.assertEqual(r.status_code, 200)Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 89why, one step back89Merge branch 'release/0.6.4'Kenneth Reitzbefore adoption4f6fc98
line 90why, one step back90 def test_HTTP_302_GET(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 91why, one step back91 r = get(httpbin('redirect', '1'), allow_redirects=False)Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 92why, one step back92 self.assertEqual(r.status_code, 302)Merge branch 'release/0.6.4'Kenneth Reitzbefore adoption4f6fc98
line 93why, one step back93documentation updateKenneth Reitzbefore adoption4a3bee6
line 94why, one step back94Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
lines 95–96why, one step back95 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 back97Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 98why, one step back98 r = get(httpbin('user-agent'), headers=heads)Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 99why, one step back99blahKenneth Reitzbefore adoptionb0e2e4f
line 100why, one step back100 assert heads['User-agent'] in r.textMerge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
lines 101–102why, one step back101 self.assertEqual(r.status_code, 200)102Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 103why, one step back103Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
lines 104–106why, one step back104 def test_HTTP_200_OK_GET_WITH_MIXED_PARAMS(self):105 heads = {'User-agent': 'Mozilla/5.0'}106Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 107why, one step back107 r = get(httpbin('get') + '?test=true', params={'q': 'test'}, headers=heads)Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 108why, one step back108 self.assertEqual(r.status_code, 200)Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 109why, one step back109Merge branch '400-header_expand-unicode' of https://github.com/acdha/requests into developKenneth Reitzbefore adoption1b6f1b0
lines 110–113why, one step back110 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 back114 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 back115Merge branch '400-header_expand-unicode' of https://github.com/acdha/requests into developKenneth Reitzbefore adoption1b6f1b0
lines 116–119why, one step back116 # 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 back120121 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 back163Merge branch 'mgiuca-uri-cleanup-nonpath' into developKenneth Reitzbefore adoptionb887ea3
lines 164–186why, one step back164 # Re-run all of the same tests on the query part of the URI165 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))186Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 187why, one step back187Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
lines 188–189why, one step back188 def test_user_agent_transfers(self):189 """Issue XX"""Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 190why, one step back190Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
lines 191–194why, one step back191 heads = {192 'User-agent':193 'Mozilla/5.0 (github.com/kennethreitz/requests)'194 }Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 195why, one step back195Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 196why, one step back196 r = get(httpbin('user-agent'), headers=heads);blahKenneth Reitzbefore adoptionb0e2e4f
line 197why, one step back197 self.assertTrue(heads['User-agent'] in r.text)Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 198why, one step back198Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
lines 199–203why, one step back199 heads = {200 'user-agent':201 'Mozilla/5.0 (github.com/kennethreitz/requests)'202 }203Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 204why, one step back204 r = get(httpbin('user-agent'), headers=heads);blahKenneth Reitzbefore adoptionb0e2e4f
line 205why, one step back205 self.assertTrue(heads['user-agent'] in r.text)Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 206why, one step back206Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 207why, one step back207Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 208why, one step back208 def test_HTTP_200_OK_HEAD(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 209why, one step back209 r = head(httpbin('/get'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 210why, one step back210 self.assertEqual(r.status_code, 200)documentation updateKenneth Reitzbefore adoption4a3bee6
line 211why, one step back211Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
lines 212–213why, one step back212213 def test_HTTP_200_OK_PUT(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 214why, one step back214 r = put(httpbin('put'))Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
lines 215–217why, one step back215 self.assertEqual(r.status_code, 200)216217Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
line 218why, one step back218 def test_BASICAUTH_TUPLE_HTTP_200_OK_GET(self):documentation updateKenneth Reitzbefore adoption4a3bee6
line 219why, one step back219Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 220why, one step back220 for service in SERVICES:Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4
line 221why, one step back221Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 222–223why, one step back222 auth = ('user', 'pass')223 url = service('basic-auth', 'user', 'pass')Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa
line 224why, one step back224Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 225why, one step back225 r = get(url, auth=auth)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 226why, one step back226 self.assertEqual(r.status_code, 200)Merge branch 'release/0.2.4'Kenneth Reitzbefore adoptiond2cdefa
line 227why, one step back227Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 228why, one step back228 r = get(url)Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
lines 229–232why, one step back229 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 back233 r = get(url, session=s)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 234–235why, one step back234 self.assertEqual(r.status_code, 200)235Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
line 236why, one step back236Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
lines 237–243why, one step back237 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')243Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 244why, one step back244 r = get(url, auth=auth)Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
lines 245–247why, one step back245 self.assertEqual(r.status_code, 200)246247 auth = ('user', 'pass')Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 248why, one step back248 r = get(url, auth=auth)Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
lines 249–250why, one step back249 self.assertEqual(r.status_code, 200)250Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 251why, one step back251 r = get(url)Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
lines 252–255why, one step back252 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 back256 r = get(url, session=s)Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
lines 257–259why, one step back257 self.assertEqual(r.status_code, 200)258259Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
lines 260–263why, one step back260 def test_DIGESTAUTH_HTTP_200_OK_GET(self):261262 for service in SERVICES:263Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
line 264why, one step back264 auth = HTTPDigestAuth('user', 'pass')Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
lines 265–266why, one step back265 url = service('digest-auth', 'auth', 'user', 'pass')266Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 267why, one step back267 r = get(url, auth=auth)Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
lines 268–269why, one step back268 self.assertEqual(r.status_code, 200)269Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 270why, one step back270 r = get(url)Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
lines 271–274why, one step back271 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 back275 r = get(url, session=s)Merge branch 'develop'Kenneth Reitzbefore adoption6b9cb05
line 276why, one step back276 self.assertEqual(r.status_code, 200)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 277why, one step back277Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 278why, one step back278 def test_POSTBIN_GET_POST_FILES(self):Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 279why, one step back279Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 280why, one step back280 for service in SERVICES:Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4
line 281why, one step back281Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 282why, one step back282 url = service('post')Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 283why, one step back283 post1 = post(url).raise_for_status()Merge branch 'release/0.2.1'Kenneth Reitzbefore adoptione09efc4
line 284why, one step back284Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
lines 285–286why, one step back285 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 back287Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 288why, one step back288 post2 = post(url, files={'some': open('test_requests.py')})Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 289why, one step back289 self.assertEqual(post2.status_code, 200)Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 290why, one step back290Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 291why, one step back291 post3 = post(url, data='[{"some": "json"}]')Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 292–294why, one step back292 self.assertEqual(post3.status_code, 200)293294Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 295why, one step back295 def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 296why, one step back296Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 297why, one step back297 for service in SERVICES:Merge branch 'release/0.3.0'Kenneth Reitzbefore adoption044252e
line 298why, one step back298Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 299why, one step back299 url = service('post')Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
lines 300–302why, one step back300 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 back303Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 304why, one step back304 self.assertEqual(post1.status_code, 200)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 305–306why, one step back305306Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
lines 307–308why, one step back307 def test_POSTBIN_GET_POST_FILES_WITH_HEADERS(self):308Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 309why, one step back309 for service in SERVICES:Merge branch 'develop'Kenneth Reitzbefore adoptioncc16073
line 310why, one step back310Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 311why, one step back311 url = service('post')Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 312why, one step back312Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 313why, one step back313 post2 = post(url,Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 314–315why, one step back314 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 back316Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 317why, one step back317 self.assertEqual(post2.status_code, 200)Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 318why, one step back318Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 319why, one step back319Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 320why, one step back320 def test_nonzero_evaluation(self):Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 321why, one step back321Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 322why, one step back322 for service in SERVICES:Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 323why, one step back323Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 324why, one step back324 r = get(service('status', '500'))Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 325why, one step back325 self.assertEqual(bool(r), False)Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 326why, one step back326Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 327why, one step back327 r = get(service('/get'))Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 328–330why, one step back328 self.assertEqual(bool(r), True)329330Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 331why, one step back331 def test_request_ok_set(self):Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 332why, one step back332Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 333why, one step back333 for service in SERVICES:Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 334why, one step back334Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 335why, one step back335 r = get(service('status', '404'))Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 336–337why, one step back336 # print r.status_code337 # r.raise_for_status()Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 338–340why, one step back338 self.assertEqual(r.ok, False)339340Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 341why, one step back341 def test_status_raising(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 342why, one step back342 r = get(httpbin('status', '404'))Merge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8
line 343why, one step back343 self.assertRaises(HTTPError, r.raise_for_status)Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 344why, one step back344Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 345why, one step back345 r = get(httpbin('status', '200'))Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
lines 346–347why, one step back346 self.assertFalse(r.error)347 r.raise_for_status()Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 348why, one step back348Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 349why, one step back349Merge pull request #333 from bryanhelmig/developKenneth Reitzbefore adoption281e059
lines 350–353why, one step back350 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 back354 self.assertRaises(HTTPError, get, *args, **kwargs)Merge pull request #333 from bryanhelmig/developKenneth Reitzbefore adoption281e059
line 355why, one step back355Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 356why, one step back356 r = get(httpbin('status', '200'))Merge pull request #333 from bryanhelmig/developKenneth Reitzbefore adoption281e059
lines 357–359why, one step back357 self.assertEqual(r.status_code, 200)358359Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
line 360why, one step back360 def test_decompress_gzip(self):documentation updateKenneth Reitzbefore adoption4a3bee6
line 361why, one step back361Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 362why, one step back362 r = get(httpbin('gzip'))Merge branch 'release/0.3.2'Kenneth Reitzbefore adoption642c667
lines 363–364why, one step back363 r.content.decode('ascii')364Merge pull request #368 from jgorset/unicode-response-urlKenneth Reitzbefore adoption99f6581
lines 365–370why, one step back365 def test_response_has_unicode_url(self):366367 for service in SERVICES:368369 url = service('get')370Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 371why, one step back371 response = get(url)Merge pull request #368 from jgorset/unicode-response-urlKenneth Reitzbefore adoption99f6581
line 372why, one step back372 assert isinstanceKenneth Reitzbefore adoption57ba337
line 373why, one step back373 assert isinstance(response.url, str)Merge pull request #368 from jgorset/unicode-response-urlKenneth Reitzbefore adoption99f6581
line 374why, one step back374Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 375why, one step back375Merge branch 'release/0.3.3'Kenneth Reitzbefore adoption7215452
line 376why, one step back376 def test_unicode_get(self):Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17
line 377why, one step back377Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 378why, one step back378 for service in SERVICES:Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 379why, one step back379Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 380why, one step back380 url = service('/get')Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 381why, one step back381Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
lines 382–386why, one step back382 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 back387Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 388why, one step back388Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17
line 389why, one step back389 def test_httpauth_recursion(self):Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 390why, one step back390Merge branch 'develop'Kenneth Reitzbefore adoptiond1dfa02
line 391why, one step back391 http_auth = HTTPBasicAuth('user', 'BADpass')Merge branch 'release/0.3.4'Kenneth Reitzbefore adoption0c00a17
line 392why, one step back392Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 393why, one step back393 for service in SERVICES:Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 394why, one step back394 r = get(service('basic-auth', 'user', 'pass'), auth=http_auth)blahKenneth Reitzbefore adoptionb0e2e4f
line 395why, one step back395 self.assertEqual(r.status_code, 401)Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 396why, one step back396Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
lines 397–399why, one step back397398 def test_urlencoded_post_data(self):399Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 400why, one step back400 for service in SERVICES:Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 401why, one step back401Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 402why, one step back402 r = post(service('post'), data=dict(test='fooaowpeuf'))Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 403why, one step back403blahKenneth Reitzbefore adoptionb0e2e4f
lines 404–406why, one step back404 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 back407blahKenneth Reitzbefore adoptionb0e2e4f
line 408why, one step back408 rbody = json.loads(r.text)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 409why, one step back409blahKenneth Reitzbefore adoptionb0e2e4f
lines 410–411why, one step back410 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 back412413Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 414why, one step back414 def test_nonurlencoded_post_data(self):Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 415why, one step back415Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 416why, one step back416 for service in SERVICES:Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 417why, one step back417Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 418why, one step back418 r = post(service('post'), data='fooaowpeuf')Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 419why, one step back419blahKenneth Reitzbefore adoptionb0e2e4f
lines 420–422why, one step back420 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 back423blahKenneth Reitzbefore adoptionb0e2e4f
line 424why, one step back424 rbody = json.loads(r.text)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 425–426why, one step back425 # Body wasn't valid url encoded data, so the server returns None as426 # "form" and the raw body as "data".oh snapKenneth Reitzbefore adoptione7bcc3b
lines 427–428why, one step back427428 assert rbody.get('form') in (None, {})blahKenneth Reitzbefore adoptionb0e2e4f
line 429why, one step back429 self.assertEqual(rbody.get('data'), 'fooaowpeuf')Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 430–431why, one step back430431Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
lines 432–433why, one step back432 def test_urlencoded_post_querystring(self):433Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 434why, one step back434 for service in SERVICES:Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 435why, one step back435Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 436why, one step back436 r = post(service('post'), params=dict(test='fooaowpeuf'))Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 437why, one step back437blahKenneth Reitzbefore adoptionb0e2e4f
lines 438–440why, one step back438 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 back441blahKenneth Reitzbefore adoptionb0e2e4f
lines 442–444why, one step back442 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 back445446Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
lines 447–448why, one step back447 def test_urlencoded_post_query_and_data(self):448Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 449why, one step back449 for service in SERVICES:Merge branch 'release/0.5.0'Kenneth Reitzbefore adoption2d98ca7
line 450why, one step back450Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 451why, one step back451 r = post(Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 452–455why, one step back452 service('post'),453 params=dict(test='fooaowpeuf'),454 data=dict(test2="foobar"))455blahKenneth Reitzbefore adoptionb0e2e4f
lines 456–458why, one step back456 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 back459blahKenneth Reitzbefore adoptionb0e2e4f
lines 460–462why, one step back460 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 back463464Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
line 465why, one step back465 def test_nonurlencoded_postdata(self):Merge branch 'release/0.4.1'Kenneth Reitzbefore adoptionadd6fea
line 466why, one step back466Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 467–468why, one step back467 for service in SERVICES:468Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 469why, one step back469 r = post(service('post'), data="foobar")Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 470why, one step back470blahKenneth Reitzbefore adoptionb0e2e4f
lines 471–472why, one step back471 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 back473blahKenneth Reitzbefore adoptionb0e2e4f
line 474why, one step back474 rbody = json.loads(r.text)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 475why, one step back475oh snapKenneth Reitzbefore adoptione7bcc3b
line 476why, one step back476 assert rbody.get('form') in (None, {})blahKenneth Reitzbefore adoptionb0e2e4f
line 477why, one step back477 self.assertEqual(rbody.get('data'), 'foobar')Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 478–479why, one step back478479Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 480why, one step back480 # def test_idna(self):Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 481why, one step back481 # r = get(u'http://➡.ws/httpbin')Merge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 482why, one step back482 # assert 'httpbin' in r.urlMerge branch 'release/0.3.3'Kenneth Reitzbefore adoption7215452
line 483why, one step back483Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 484why, one step back484Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc
lines 485–486why, one step back485 def test_urlencoded_get_query_multivalued_param(self):486Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 487–488why, one step back487 for service in SERVICES:488Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 489why, one step back489 r = get(service('get'), params=dict(test=['foo','baz']))blahKenneth Reitzbefore adoptionb0e2e4f
lines 490–491why, one step back490 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 back492493Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc
lines 494–495why, one step back494 def test_urlencoded_post_querystring_multivalued(self):495Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 496–497why, one step back496 for service in SERVICES:497Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 498why, one step back498 r = post(service('post'), params=dict(test=['foo','baz']))blahKenneth Reitzbefore adoptionb0e2e4f
lines 499–501why, one step back499 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 back502blahKenneth Reitzbefore adoptionb0e2e4f
lines 503–505why, one step back503 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 back506507Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc
lines 508–509why, one step back508 def test_urlencoded_post_query_multivalued_and_data(self):509Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 510why, one step back510 for service in SERVICES:Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc
line 511why, one step back511Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 512why, one step back512 r = post(Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 513–516why, one step back513 service('post'),514 params=dict(test=['foo','baz']),515 data=dict(test2="foobar",test3=['foo','baz']))516blahKenneth Reitzbefore adoptionb0e2e4f
lines 517–519why, one step back517 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 back520blahKenneth Reitzbefore adoptionb0e2e4f
lines 521–522why, one step back521 # print(r.text)522 # print('-----------------------')Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 523why, one step back523blahKenneth Reitzbefore adoptionb0e2e4f
lines 524–528why, one step back524 rbody = json.loads(r.text)525 self.assertEqual(rbody.get('form'), dict(test2='foobar',test3=['foo','baz']))526 self.assertEqual(rbody.get('data'), '')527528Merge branch 'redirect-no-follow' of https://github.com/millerdev/requestsKenneth Reitzbefore adoption98c719f
lines 529–532why, one step back529 def test_GET_no_redirect(self):530531 for service in SERVICES:532Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 533why, one step back533 r = get(service('redirect', '3'), allow_redirects=False)blahKenneth Reitzbefore adoptionb0e2e4f
lines 534–535why, one step back534 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 back536537538 def test_HEAD_no_redirect(self):539540 for service in SERVICES:541Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 542why, one step back542 r = head(service('redirect', '3'), allow_redirects=False)blahKenneth Reitzbefore adoptionb0e2e4f
lines 543–544why, one step back543 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 back545546Merge branch 'release/0.5.1'Kenneth Reitzbefore adoption95ba6fc
lines 547–548why, one step back547 def test_redirect_history(self):548Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 549–550why, one step back549 for service in SERVICES:550Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 551why, one step back551 r = get(service('redirect', '3'))blahKenneth Reitzbefore adoptionb0e2e4f
lines 552–553why, one step back552 self.assertEqual(r.status_code, 200)553 self.assertEqual(len(r.history), 3)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 554–559why, one step back554555556 def test_relative_redirect_history(self):557558 for service in SERVICES:559Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 560why, one step back560 r = get(service('relative-redirect', '3'))blahKenneth Reitzbefore adoptionb0e2e4f
lines 561–562why, one step back561 self.assertEqual(r.status_code, 200)562 self.assertEqual(len(r.history), 3)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 563–566why, one step back563564565 def test_session_HTTP_200_OK_GET(self):566Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 567why, one step back567 s = requests.session()Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 568why, one step back568 r = get(httpbin('/get'), session=s)Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 569–575why, one step back569 self.assertEqual(r.status_code, 200)570571572 def test_session_persistent_headers(self):573574 heads = {'User-agent': 'Mozilla/5.0'}575Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 576why, one step back576 s = requests.session()Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 577why, one step back577 s.headers = headsMerge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 578why, one step back578Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 579why, one step back579 # Make 2 requests from Session object, should send header both timesStandard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 580why, one step back580 r1 = get(httpbin('user-agent'), session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 581why, one step back581 assert heads['User-agent'] in r1.textMerge branch 'develop'Kenneth Reitzbefore adoption81d5997
line 582why, one step back582Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 583why, one step back583 r2 = get(httpbin('user-agent'), session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 584why, one step back584 assert heads['User-agent'] in r2.textMerge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
lines 585–586why, one step back585586 new_heads = {'User-agent': 'blah'}Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 587why, one step back587 r3 = get(httpbin('user-agent'), headers=new_heads, session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 588why, one step back588 assert new_heads['User-agent'] in r3.textMerge branch 'develop'Kenneth Reitzbefore adoption82e8fdb
line 589why, one step back589Merge branch 'develop'Kenneth Reitzbefore adoption81d5997
lines 590–591why, one step back590 self.assertEqual(r2.status_code, 200)591Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52
lines 592–606why, one step back592 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')606Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 607why, one step back607 response = get(Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52
lines 608–613why, one step back608 url = url,609 hooks = {610 'args': add_foo_header611 }612 )613blahKenneth Reitzbefore adoptionb0e2e4f
line 614why, one step back614 assert 'foo' in response.textFacilitate for multiple hooksJohannes Gorsetbefore adoption7647e52
lines 615–640why, one step back615616 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')640Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 641why, one step back641 response = get(Facilitate for multiple hooksJohannes Gorsetbefore adoption7647e52
lines 642–647why, one step back642 url = url,643 hooks = {644 'args': [add_foo_header, add_bar_header]645 }646 )647blahKenneth Reitzbefore adoptionb0e2e4f
lines 648–649why, one step back648 assert 'foo' in response.text649 assert 'bar' in response.textFacilitate for multiple hooksJohannes Gorsetbefore adoption7647e52
line 650why, one step back650Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
line 651why, one step back651 def test_session_persistent_cookies(self):Merge branch 'release/0.3.3'Kenneth Reitzbefore adoption7215452
line 652why, one step back652Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 653–656why, one step back653 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 back657 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 back659660 # Those cookies persist transparently.blahKenneth Reitzbefore adoptionb0e2e4f
line 661why, one step back661 c = json.loads(r.text).get('cookies')Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 662–664why, one step back662 assert c == _c663664 # Double check.Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 665why, one step back665 r = get(httpbin('cookies'), cookies={}, session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 666why, one step back666 c = json.loads(r.text).get('cookies')Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 667–669why, one step back667 assert c == _c668669 # Remove a cookie by setting it's value to None.Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 670why, one step back670 r = get(httpbin('cookies'), cookies={'bessie': None}, session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 671why, one step back671 c = json.loads(r.text).get('cookies')Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 672–676why, one step back672 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 back677 r = get(httpbin('cookies'), session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 678why, one step back678 c = json.loads(r.text).get('cookies')Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 679–681why, one step back679 assert c == _c680681 # Have the server set a cookie.Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 682why, one step back682 r = get(httpbin('cookies', 'set', 'k', 'v'), allow_redirects=True, session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 683why, one step back683 c = json.loads(r.text).get('cookies')Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 684–687why, one step back684685 assert 'k' in c686687 # And server-set cookie persistience.Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 688why, one step back688 r = get(httpbin('cookies'), session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 689why, one step back689 c = json.loads(r.text).get('cookies')Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 690–694why, one step back690691 assert 'k' in c692693694Merge branch 'develop'Kenneth Reitzbefore adoption23efd56
lines 695–698why, one step back695 def test_session_persistent_params(self):696697 params = {'a': 'a_test'}698Merge branch 'develop'Kenneth Reitzbefore adoption5b5b3de
line 699why, one step back699 s = requests.session()Merge branch 'develop'Kenneth Reitzbefore adoption23efd56
lines 700–702why, one step back700 s.params = params701702 # Make 2 requests from Session object, should send header both timesStandard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 703why, one step back703 r1 = get(httpbin('get'), session=s)blahKenneth Reitzbefore adoptionb0e2e4f
line 704why, one step back704 assert params['a'] in r1.textMerge branch 'develop'Kenneth Reitzbefore adoption23efd56
lines 705–708why, one step back705706707 params2 = {'b': 'b_test'}708Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 709why, one step back709 r2 = get(httpbin('get'), params=params2, session=s)blahKenneth Reitzbefore adoptionb0e2e4f
lines 710–711why, one step back710 assert params['a'] in r2.text711 assert params2['b'] in r2.textMerge branch 'develop'Kenneth Reitzbefore adoption23efd56
lines 712–715why, one step back712713714 params3 = {'b': 'b_test', 'a': None, 'c': 'c_test'}715Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 716why, one step back716 r3 = get(httpbin('get'), params=params3, session=s)Merge branch 'develop'Kenneth Reitzbefore adoption23efd56
line 717why, one step back717blahKenneth Reitzbefore adoptionb0e2e4f
lines 718–720why, one step back718 assert not params['a'] in r3.text719 assert params3['b'] in r3.text720 assert params3['c'] in r3.textMerge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8
lines 721–722why, one step back721722 def test_invalid_content(self):Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 723–726why, one step back723 # 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 back727 r = get(hah, allow_redirects=False)Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 728–731why, one step back728 except requests.ConnectionError:729 pass # \o/730 else:731 assert FalseMerge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8
line 732why, one step back732Merge branch 'develop'Kenneth Reitzbefore adoption6e9cb09
lines 733–734why, one step back733734 config = {'safe_mode': True}Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 735why, one step back735 r = get(hah, allow_redirects=False, config=config)Merge branch 'develop'Kenneth Reitzbefore adoptiond0b96f8
line 736why, one step back736 assert r.content == NoneMerge branch 'develop'Kenneth Reitzbefore adoption23efd56
line 737why, one step back737Merge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d
lines 738–739why, one step back738 def test_cached_response(self):739Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 740why, one step back740 r1 = get(httpbin('get'), prefetch=False)blahKenneth Reitzbefore adoptionb0e2e4f
line 741why, one step back741 assert not r1._contentMerge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d
line 742why, one step back742 assert r1.contentblahKenneth Reitzbefore adoptionb0e2e4f
line 743why, one step back743 assert r1.textMerge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d
line 744why, one step back744Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 745why, one step back745 r2 = get(httpbin('get'), prefetch=True)Merge branch 'develop'Kenneth Reitzbefore adoption19a2a6c
line 746why, one step back746 assert r2._contentMerge branch 'develop'Kenneth Reitzbefore adoption8c1fd5d
line 747why, one step back747 assert r2.contentblahKenneth Reitzbefore adoptionb0e2e4f
line 748why, one step back748 assert r2.textMerge branch 'develop'Kenneth Reitzbefore adoption19a2a6c
lines 749–754why, one step back749750 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 back755 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 back756 lines = list(r.iter_lines())757 len_lines = len(lines)Merge branch 'develop'Kenneth Reitzbefore adoption19a2a6c
lines 758–759why, one step back758759 self.assertEqual(i, len_lines)Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
lines 760–768why, one step back760761 # 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 contentsStandard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 769why, one step back769 r = get(httpbin('get'))oh snapKenneth Reitzbefore adoptione7bcc3b
line 770why, one step back770 r.raw = StringIO(quote)Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
lines 771–781why, one step back771772 # 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 sequencesStandard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 782why, one step back782 r = get('http://_/', session=safe)blahKenneth Reitzbefore adoptionb0e2e4f
line 783why, one step back783 self.assertEqual(list(r.iter_lines()), []) assert isinstanceKenneth Reitzbefore adoption57ba337
line 784why, one step back784 assert isinstance(r.error, requests.exceptions.ConnectionError)Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
line 785why, one step back785Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 786why, one step back786 r = get('http://_/', session=safe)blahKenneth Reitzbefore adoptionb0e2e4f
line 787why, one step back787 self.assertEqual(list(r.iter_content()), []) assert isinstanceKenneth Reitzbefore adoptionc4eb930
line 788why, one step back788 assert isinstance(r.error, requests.exceptions.ConnectionError)Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
lines 789–790why, one step back789790 # When not in safe mode, should raise Timeout exceptionfix 26Kenneth Reitzbefore adoption4493acc
lines 791–792why, one step back791 self.assertRaises(792 requests.exceptions.Timeout,Standard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 793why, one step back793 get,fix 26Kenneth Reitzbefore adoption4493acc
line 794why, one step back794 httpbin('stream', '1000'), timeout=0.0001)Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
lines 795–796why, one step back795796 # In safe mode, should return a blank responseStandard tests from RequestsTestSuite run using async apiPiotr Dobrogostbefore adoptionc430b60
line 797why, one step back797 r = get(httpbin('stream', '1000'), timeout=0.0001,Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
line 798why, one step back798 config=dict(safe_mode=True))dammit, i changed againKenneth Reitzbefore adoptiona939423
line 799why, one step back799 assert r.content is None assert isinstanceKenneth Reitzbefore adoptionc4eb930
line 800why, one step back800 assert isinstance(r.error, requests.exceptions.Timeout)binary data upload bug testKenneth Reitzbefore adoption0d8c08c
lines 801–805why, one step back801802 def test_upload_binary_data(self):803804 r = requests.get(httpbin('post'), auth=('a', 'b'), data='\xff')805Merge branch 'develop'Kenneth Reitzbefore adoption9ed9304
line 806why, one step back806Merge branch 'develop'Kenneth Reitzbefore adoption23efd56
line 807why, one step back807documentation updateKenneth Reitzbefore adoption4a3bee6
line 808why, one step back808if __name__ == '__main__':Merge branch 'release/0.9.4'Kenneth Reitzbefore adoption952970f
line 809why, one step back809 unittest.main()