make test-parameters optional

This commit is contained in:
Mike Fährmann
2015-12-13 03:56:29 +01:00
parent 9c9b1e112a
commit 0961ece989

View File

@@ -8,12 +8,12 @@
# published by the Free Software Foundation. # published by the Free Software Foundation.
import unittest import unittest
import gallery_dl.extractor as extractor from gallery_dl import extractor, jobs, config
import gallery_dl.jobs as jobs
class TestExttractors(unittest.TestCase): class TestExttractors(unittest.TestCase):
def test_extractors(self): def test_extractors(self):
config.load()
for extr in extractor.extractors(): for extr in extractor.extractors():
if not hasattr(extr, "test"): if not hasattr(extr, "test"):
continue continue
@@ -25,7 +25,9 @@ class TestExttractors(unittest.TestCase):
def run_test(self, url, result): def run_test(self, url, result):
hjob = jobs.HashJob(url) hjob = jobs.HashJob(url)
hjob.run() hjob.run()
if "url" in result:
self.assertEqual(hjob.hash_url.hexdigest(), result["url"]) self.assertEqual(hjob.hash_url.hexdigest(), result["url"])
if "keyword" in result:
self.assertEqual(hjob.hash_keyword.hexdigest(), result["keyword"]) self.assertEqual(hjob.hash_keyword.hexdigest(), result["keyword"])
if __name__ == '__main__': if __name__ == '__main__':