From 2fa575b27309e34c5c758f580372483da6c0ad17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 27 Feb 2017 23:05:08 +0100 Subject: [PATCH] restore exception-testing to its old form --- gallery_dl/job.py | 8 ++------ test/test_extractors.py | 5 +++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gallery_dl/job.py b/gallery_dl/job.py index b51fe456..5a992267 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -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) diff --git a/test/test_extractors.py b/test/test_extractors.py index a99bb794..3c3b3264 100644 --- a/test/test_extractors.py +++ b/test/test_extractors.py @@ -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