From 3fa74ca4d75d6f89f6b6f2432522a87eec760f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 17 Jul 2024 22:29:09 +0200 Subject: [PATCH] [tests] enable test results for external extractors (#5262) https://github.com/mikf/gallery-dl/issues/5262#issuecomment-2231649983 --- test/test_results.py | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/test/test_results.py b/test/test_results.py index 140b71b7..84b20917 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -87,37 +87,32 @@ class TestExtractorResults(unittest.TestCase): def _run_test(self, result): result.pop("#comment", None) auth = result.pop("#auth", None) - only_matching = (len(result) <= 3) + + extr = result["#class"].from_url(result["#url"]) + if not extr: + raise exception.NoExtractorError() + if len(result) <= 3: + return # only matching if auth is None: auth = (result["#category"][1] in AUTH) elif not auth: + # auth explicitly disabled for key in AUTH_CONFIG: config.set((), key, None) - if auth: - extr = result["#class"].from_url(result["#url"]) - if not any(extr.config(key) for key in AUTH_CONFIG): - self._skipped.append((result["#url"], "no auth")) - only_matching = True + if auth and not any(extr.config(key) for key in AUTH_CONFIG): + return self._skipped.append((result["#url"], "no auth")) - if only_matching: - content = False - else: - if "#options" in result: - for key, value in result["#options"].items(): - key = key.split(".") - config.set(key[:-1], key[-1], value) - if "#range" in result: - config.set((), "image-range" , result["#range"]) - config.set((), "chapter-range", result["#range"]) - content = ("#sha1_content" in result) + if "#options" in result: + for key, value in result["#options"].items(): + key = key.split(".") + config.set(key[:-1], key[-1], value) + if "#range" in result: + config.set((), "image-range" , result["#range"]) + config.set((), "chapter-range", result["#range"]) - tjob = ResultJob(result["#url"], content=content) - self.assertEqual(result["#class"], tjob.extractor.__class__, "#class") - - if only_matching: - return + tjob = ResultJob(extr, content=("#sha1_content" in result)) if "#exception" in result: with self.assertRaises(result["#exception"], msg="#exception"):