mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-24 03:01:53 +00:00
[travis] Run tests in parallel
[test_download] Print test names in case of network errors [test_download] Add comments for nose parameters [test_download] Modify outtmpl to prevent info JSON filename conflicts Thanks @jaimeMF for the idea. [travis] Only download tests should be run in parallel
This commit is contained in:
parent
c58b7ffef4
commit
8936f68a0b
2 changed files with 11 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
||||||
DOWNLOAD_TESTS="age_restriction|download|subtitles|write_annotations|iqiyi_sdk_interpreter"
|
DOWNLOAD_TESTS="age_restriction|download|subtitles|write_annotations|iqiyi_sdk_interpreter"
|
||||||
|
|
||||||
test_set=""
|
test_set=""
|
||||||
|
multiprocess_args=""
|
||||||
|
|
||||||
case "$YTDL_TEST_SET" in
|
case "$YTDL_TEST_SET" in
|
||||||
core)
|
core)
|
||||||
|
@ -10,10 +11,11 @@ case "$YTDL_TEST_SET" in
|
||||||
;;
|
;;
|
||||||
download)
|
download)
|
||||||
test_set="-I test_(?!$DOWNLOAD_TESTS).+\.py"
|
test_set="-I test_(?!$DOWNLOAD_TESTS).+\.py"
|
||||||
|
multiprocess_args="--processes=4 --process-timeout=540"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
nosetests test --verbose $test_set
|
nosetests test --verbose $test_set $multiprocess_args
|
||||||
|
|
|
@ -65,6 +65,10 @@ defs = gettestcases()
|
||||||
|
|
||||||
|
|
||||||
class TestDownload(unittest.TestCase):
|
class TestDownload(unittest.TestCase):
|
||||||
|
# Parallel testing in nosetests. See
|
||||||
|
# http://nose.readthedocs.org/en/latest/doc_tests/test_multiprocess/multiprocess.html
|
||||||
|
_multiprocess_shared_ = True
|
||||||
|
|
||||||
maxDiff = None
|
maxDiff = None
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -73,7 +77,7 @@ class TestDownload(unittest.TestCase):
|
||||||
# Dynamically generate tests
|
# Dynamically generate tests
|
||||||
|
|
||||||
|
|
||||||
def generator(test_case):
|
def generator(test_case, tname):
|
||||||
|
|
||||||
def test_template(self):
|
def test_template(self):
|
||||||
ie = youtube_dl.extractor.get_info_extractor(test_case['name'])
|
ie = youtube_dl.extractor.get_info_extractor(test_case['name'])
|
||||||
|
@ -102,6 +106,7 @@ def generator(test_case):
|
||||||
return
|
return
|
||||||
|
|
||||||
params = get_params(test_case.get('params', {}))
|
params = get_params(test_case.get('params', {}))
|
||||||
|
params['outtmpl'] = tname + '_' + params['outtmpl']
|
||||||
if is_playlist and 'playlist' not in test_case:
|
if is_playlist and 'playlist' not in test_case:
|
||||||
params.setdefault('extract_flat', 'in_playlist')
|
params.setdefault('extract_flat', 'in_playlist')
|
||||||
params.setdefault('skip_download', True)
|
params.setdefault('skip_download', True)
|
||||||
|
@ -146,7 +151,7 @@ def generator(test_case):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if try_num == RETRIES:
|
if try_num == RETRIES:
|
||||||
report_warning('Failed due to network errors, skipping...')
|
report_warning('%s failed due to network errors, skipping...' % tname)
|
||||||
return
|
return
|
||||||
|
|
||||||
print('Retrying: {0} failed tries\n\n##########\n\n'.format(try_num))
|
print('Retrying: {0} failed tries\n\n##########\n\n'.format(try_num))
|
||||||
|
@ -221,12 +226,12 @@ def generator(test_case):
|
||||||
|
|
||||||
# And add them to TestDownload
|
# And add them to TestDownload
|
||||||
for n, test_case in enumerate(defs):
|
for n, test_case in enumerate(defs):
|
||||||
test_method = generator(test_case)
|
|
||||||
tname = 'test_' + str(test_case['name'])
|
tname = 'test_' + str(test_case['name'])
|
||||||
i = 1
|
i = 1
|
||||||
while hasattr(TestDownload, tname):
|
while hasattr(TestDownload, tname):
|
||||||
tname = 'test_%s_%d' % (test_case['name'], i)
|
tname = 'test_%s_%d' % (test_case['name'], i)
|
||||||
i += 1
|
i += 1
|
||||||
|
test_method = generator(test_case, tname)
|
||||||
test_method.__name__ = str(tname)
|
test_method.__name__ = str(tname)
|
||||||
setattr(TestDownload, test_method.__name__, test_method)
|
setattr(TestDownload, test_method.__name__, test_method)
|
||||||
del test_method
|
del test_method
|
||||||
|
|
Loading…
Reference in a new issue