def test_unseekable_file(self):
def tell_fails():
raise IOError()
ticket = get_ticket(urls=[get_http_ticket(EXAMPLE_URL)])
for num_retries in range(10):
temp_file = StringIO()
temp_file.tell = tell_fails
with mock.patch("time.sleep") as mock_sleep, \
mock.patch("logging.warning") as mock_warning:
dm = RetryCountDownloadManager(
ticket, temp_file, max_retries=num_retries)
self.assertEqual(dm.max_retries, num_retries)
self.assertRaises(exceptions.RetryableError, dm.run)
self.assertEqual(dm.attempt_counts[EXAMPLE_URL], 1)
self.assertEqual(mock_sleep.call_count, 0)
self.assertEqual(mock_warning.call_count, 0)
评论列表
文章目录