1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

initialize cache-module before running tests

This commit is contained in:
Mike Fährmann 2016-03-08 18:01:35 +01:00
parent c9b7db5af5
commit 871f4c8a48
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 7 additions and 3 deletions

View File

@ -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()))

View File

@ -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