aboutsummaryrefslogtreecommitdiff
path: root/test/gentests.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2012-11-28 19:03:11 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2012-11-28 19:03:11 +0100
commit81760416054be7dcccc66b14d171872c8e13f183 (patch)
treea2f947a6719b5756e8f9340916810cbdd2ecc73a /test/gentests.py
parent6ad98fb3fda767fb8da0d3c40da408ec2a09b5d4 (diff)
downloadyoutube-dl-81760416054be7dcccc66b14d171872c8e13f183.tar.xz
Check during test runtime instead of test generation for _WORKING, and add 2.6 compat
Diffstat (limited to 'test/gentests.py')
-rwxr-xr-xtest/gentests.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/test/gentests.py b/test/gentests.py
index 8a76ff9f7..da4e3c2f6 100755
--- a/test/gentests.py
+++ b/test/gentests.py
@@ -46,6 +46,22 @@ def md5_for_file(filename, block_size=2**20):
return md5.hexdigest()
_file_md5 = md5_for_file
+
+try:
+ _skip_unless = unittest.skipUnless
+except AttributeError: # Python 2.6
+ def _skip_unless(cond, reason='No reason given'):
+ def resfunc(f):
+ def wfunc(*args, **kwargs):
+ if cond:
+ return f(*args, **kwargs)
+ else:
+ print('Skipped test')
+ return
+ return wfunc
+ return resfunc
+_skip = lambda *args, **kwargs: _skip_unless(False, *args, **kwargs)
+
class DownloadTest(unittest.TestCase):
PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "parameters.json")
@@ -78,17 +94,15 @@ def gentests():
name = d['name']
ie = getattr(youtube_dl.InfoExtractors, name + 'IE')
testf.write('\n')
- if not ie._WORKING:
- write('@unittest.skip("IE marked as not _WORKING")')
- elif not d['file']:
- write('@unittest.skip("No output file specified")')
+ write('@_skip_unless(youtube_dl.InfoExtractors.' + name + 'IE._WORKING, "IE marked as not _WORKING")')
+ if not d['file']:
+ write('@_skip("No output file specified")')
elif 'skip' in d:
- write('@unittest.skip(' + repr(d['skip']) + ')')
+ write('@_skip(' + repr(d['skip']) + ')')
write('def test_' + name + '(self):')
- write(' ' + name + 'IE = youtube_dl.InfoExtractors.' + name + 'IE')
write(' filename = ' + repr(d['file']))
write(' fd = FileDownloader(self.parameters)')
- write(' fd.add_info_extractor(' + name + 'IE())')
+ write(' fd.add_info_extractor(youtube_dl.InfoExtractors.' + name + 'IE())')
for ien in d.get('addIEs', []):
write(' fd.add_info_extractor(youtube_dl.InfoExtractors.' + ien + 'IE())')
write(' fd.download([' + repr(d['url']) + '])')