mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
restore exception-testing to its old form
This commit is contained in:
parent
f361cb13e0
commit
2fa575b273
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user