Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: infra_libs/test/httplib2_utils_test.py

Issue 2153483002: RetriableHttp to sleep between retries (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra_libs/httplib2_utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra_libs/test/httplib2_utils_test.py
diff --git a/infra_libs/test/httplib2_utils_test.py b/infra_libs/test/httplib2_utils_test.py
index 9e32bc40402c1e5aefd8d29b9d574af3ab0b3acf..21d57354cdffbf5374a612a83877d6bbecc01689 100644
--- a/infra_libs/test/httplib2_utils_test.py
+++ b/infra_libs/test/httplib2_utils_test.py
@@ -162,14 +162,16 @@ class RetriableHttplib2Test(unittest.TestCase):
self.assertTrue(self.http.ignore_etag)
self.assertTrue(self.http._http.ignore_etag)
- def test_succeed(self):
+ @mock.patch('time.sleep', autospec=True)
Sergey Berezin 2016/07/14 21:10:17 nit: in this case it's likely not as relevant, but
+ def test_succeed(self, _sleep):
self.http._http.request.return_value = (
httplib2.Response({'status': 400}), 'content')
response, _ = self.http.request('http://foo/')
self.assertEqual(400, response.status)
self.http._http.request.assert_has_calls([ self._MOCK_REQUEST ])
- def test_retry_succeed(self):
+ @mock.patch('time.sleep', autospec=True)
+ def test_retry_succeed(self, _sleep):
self.http._http.request.side_effect = iter([
(httplib2.Response({'status': 500}), 'content'),
httplib2.HttpLib2Error,
@@ -179,12 +181,14 @@ class RetriableHttplib2Test(unittest.TestCase):
self.assertEqual(200, response.status)
self.http._http.request.assert_has_calls([ self._MOCK_REQUEST ] * 3)
- def test_fail_exception(self):
+ @mock.patch('time.sleep', autospec=True)
+ def test_fail_exception(self, _sleep):
self.http._http.request.side_effect = httplib2.HttpLib2Error()
self.assertRaises(httplib2.HttpLib2Error, self.http.request, 'http://foo/')
self.http._http.request.assert_has_calls([ self._MOCK_REQUEST ] * 5)
- def test_fail_status_code(self):
+ @mock.patch('time.sleep', autospec=True)
+ def test_fail_status_code(self, _sleep):
self.http._http.request.return_value = (
httplib2.Response({'status': 500}), 'content')
response, _ = self.http.request('http://foo/')
« no previous file with comments | « infra_libs/httplib2_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698