Skip to content
Myr

[kennethreitz/requests#1208] adding unit test for max_retries

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Wilfred Hughes · committed by Wilfred Hughes · parent 796d322 · Browse files · 1 file+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−0 removed

  • other:+21 added−0 removed

1 file+21 added−0 removed

modified:test_requests.py+21 added
352 unmodified lines
353 def test_cannot_send_unprepared_requests(self):354 r = requests.Request(url=HTTPBIN)355 self.assertRaises(ValueError, requests.Session().send, r)356357 def test_can_specify_retries(self):358 # monkey patch urlopen359 from requests.packages.urllib3.poolmanager import HTTPConnectionPool360 old_urlopen = HTTPConnectionPool.urlopen361362 max_retries_used = []363 def urlopen(*args, **kwargs):364 """Save what value we used for retries each time we call urlopen."""365 max_retries_used.append(kwargs.get('retries'))366 return old_urlopen(*args, **kwargs)367368 HTTPConnectionPool.urlopen = urlopen369370 # do the request and check that max_retries was passed through371 requests.get(httpbin('get'), max_retries=5)372 self.assertEqual(max_retries_used, [5])373374 # undo monkey patch375 HTTPConnectionPool.urlopen = old_urlopen376 377378if __name__ == '__main__':379 unittest.main()