diff options
author | Filippo Valsorda <filippo.valsorda@gmail.com> | 2013-10-28 18:03:26 -0400 |
---|---|---|
committer | Filippo Valsorda <filippo.valsorda@gmail.com> | 2013-10-28 18:03:26 -0400 |
commit | dd508b7c4f0dd8881de07a4e8593d4fcdef9bae7 (patch) | |
tree | e6b2f70bba9f9a4709e15dd64cfd10c70aab70b6 /test/test_download.py | |
parent | 2563bcc85cc09382d7e731709b2c8a4ad96c7ea3 (diff) |
[tests] don't fail on network errors
This is suboptimal, but at least this way we will need to look at the logs
only to check for network errors that happen too often, instead of
parsing a ton of lines each time to see if there is some true test failing
Diffstat (limited to 'test/test_download.py')
-rw-r--r-- | test/test_download.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/test/test_download.py b/test/test_download.py index f136176b1..565afa1b5 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -6,7 +6,14 @@ import sys import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from test.helper import get_params, get_testcases, global_setup, try_rm, md5 +from test.helper import ( + get_params, + get_testcases, + global_setup, + try_rm, + md5, + report_warning +) global_setup() @@ -92,17 +99,22 @@ def generator(test_case): try_rm(tc_filename + '.info.json') try_rm_tcs_files() try: - for retry in range(1, RETRIES + 1): + try_num = 1 + while True: try: ydl.download([test_case['url']]) except (DownloadError, ExtractorError) as err: - if retry == RETRIES: raise - # Check if the exception is not a network related one if not err.exc_info[0] in (compat_urllib_error.URLError, socket.timeout, UnavailableVideoError): raise - print('Retrying: {0} failed tries\n\n##########\n\n'.format(retry)) + if try_num == RETRIES: + report_warning(u'Failed due to network errors, skipping...') + return + + print('Retrying: {0} failed tries\n\n##########\n\n'.format(try_num)) + + try_num += 1 else: break |