mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
parent
a276e06080
commit
5d01a64719
1 changed files with 7 additions and 5 deletions
|
@ -49,13 +49,14 @@ def setUp(self):
|
||||||
self.tearDown()
|
self.tearDown()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
for test in self.defs:
|
for fn in [ test.get('file', False) for test in self.defs ]:
|
||||||
fn = test['file']
|
|
||||||
if fn and os.path.exists(fn):
|
if fn and os.path.exists(fn):
|
||||||
os.remove(fn)
|
os.remove(fn)
|
||||||
|
|
||||||
|
|
||||||
def make_test_method(test_case):
|
### Dinamically generate tests
|
||||||
|
def generator(test_case):
|
||||||
|
|
||||||
def test_template(self):
|
def test_template(self):
|
||||||
ie = getattr(youtube_dl.InfoExtractors, test_case['name'] + 'IE')
|
ie = getattr(youtube_dl.InfoExtractors, test_case['name'] + 'IE')
|
||||||
if not ie._WORKING:
|
if not ie._WORKING:
|
||||||
|
@ -80,13 +81,14 @@ def test_template(self):
|
||||||
md5_for_file = _file_md5(test_case['file'])
|
md5_for_file = _file_md5(test_case['file'])
|
||||||
self.assertEqual(md5_for_file, test_case['md5'])
|
self.assertEqual(md5_for_file, test_case['md5'])
|
||||||
|
|
||||||
# TODO proper skipping annotations
|
|
||||||
return test_template
|
return test_template
|
||||||
|
|
||||||
|
### And add them to TestDownload
|
||||||
for test_case in defs:
|
for test_case in defs:
|
||||||
test_method = make_test_method(test_case)
|
test_method = generator(test_case)
|
||||||
test_method.__name__ = "test_{0}".format(test_case["name"])
|
test_method.__name__ = "test_{0}".format(test_case["name"])
|
||||||
setattr(TestDownload, test_method.__name__, test_method)
|
setattr(TestDownload, test_method.__name__, test_method)
|
||||||
|
del test_method
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue