1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

restore exception-testing to its old form

This commit is contained in:
Mike Fährmann 2017-02-27 23:05:08 +01:00
parent f361cb13e0
commit 2fa575b273
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 5 additions and 8 deletions

View File

@ -223,7 +223,6 @@ class TestJob(DownloadJob):
def __init__(self, url, content=False):
DownloadJob.__init__(self, url)
self.content = content
self.exception = None
self.hash_url = hashlib.sha1()
self.hash_keyword = hashlib.sha1()
self.hash_content = hashlib.sha1()
@ -231,11 +230,8 @@ class TestJob(DownloadJob):
self.fileobj = self.HashIO(self.hash_content)
def run(self):
try:
for msg in self.extractor:
self.dispatch(msg)
except Exception as e:
self.exception = e
for msg in self.extractor:
self.dispatch(msg)
def handle_url(self, url, keywords):
self.update_url(url)

View File

@ -26,6 +26,9 @@ class TestExtractors(unittest.TestCase):
def _run_test(self, extr, url, result):
tjob = job.TestJob(url, "content" in result)
self.assertEqual(extr, tjob.extractor.__class__)
if "exception" in result:
self.assertRaises(result["exception"], tjob.run)
return
tjob.run()
if "url" in result:
self.assertEqual(tjob.hash_url.hexdigest(), result["url"])
@ -33,8 +36,6 @@ class TestExtractors(unittest.TestCase):
self.assertEqual(tjob.hash_keyword.hexdigest(), result["keyword"])
if "content" in result:
self.assertEqual(tjob.hash_content.hexdigest(), result["content"])
if "exception" in result:
self.assertEqual(tjob.exception.__class__, result["exception"])
# dynamically genertate tests