From 871f4c8a48cdd9efd5e83e893c7e8ed2f8d690dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 8 Mar 2016 18:01:35 +0100 Subject: [PATCH] initialize cache-module before running tests --- test/create_test_data.py | 1 + test/test_extractors.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/create_test_data.py b/test/create_test_data.py index 2dc35c06..89a31e8d 100644 --- a/test/create_test_data.py +++ b/test/create_test_data.py @@ -30,6 +30,7 @@ def main(): for url in args.urls: job = jobs.HashJob(url, content=args.content) job.run() + print(job.extractor.__class__.__name__) print(TESTDATA_FMT.format(url, job.hash_url.hexdigest(), job.hash_keyword.hexdigest(), job.hash_content.hexdigest())) diff --git a/test/test_extractors.py b/test/test_extractors.py index 34081586..f75a05bb 100644 --- a/test/test_extractors.py +++ b/test/test_extractors.py @@ -8,15 +8,18 @@ # published by the Free Software Foundation. import unittest -from gallery_dl import extractor, jobs, config +from gallery_dl import extractor, jobs, config, cache class TestExtractors(unittest.TestCase): def setUp(self): config.load() + config.set(("cache", "file"), ":memory:") + cache.init_database() - def run_test(self, url, result): + def run_test(self, extr, url, result): hjob = jobs.HashJob(url, "content" in result) + self.assertEqual(extr, hjob.extractor.__class__) hjob.run() if "url" in result: self.assertEqual(hjob.hash_url.hexdigest(), result["url"]) @@ -31,7 +34,7 @@ def generate_test(extr): print(extr.__name__) for url, result in extr.test: print(url) - self.run_test(url, result) + self.run_test(extr, url, result) return test