initialize cache-module before running tests
This commit is contained in:
@@ -30,6 +30,7 @@ def main():
|
|||||||
for url in args.urls:
|
for url in args.urls:
|
||||||
job = jobs.HashJob(url, content=args.content)
|
job = jobs.HashJob(url, content=args.content)
|
||||||
job.run()
|
job.run()
|
||||||
|
print(job.extractor.__class__.__name__)
|
||||||
print(TESTDATA_FMT.format(url, job.hash_url.hexdigest(),
|
print(TESTDATA_FMT.format(url, job.hash_url.hexdigest(),
|
||||||
job.hash_keyword.hexdigest(), job.hash_content.hexdigest()))
|
job.hash_keyword.hexdigest(), job.hash_content.hexdigest()))
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,18 @@
|
|||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from gallery_dl import extractor, jobs, config
|
from gallery_dl import extractor, jobs, config, cache
|
||||||
|
|
||||||
class TestExtractors(unittest.TestCase):
|
class TestExtractors(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
config.load()
|
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)
|
hjob = jobs.HashJob(url, "content" in result)
|
||||||
|
self.assertEqual(extr, hjob.extractor.__class__)
|
||||||
hjob.run()
|
hjob.run()
|
||||||
if "url" in result:
|
if "url" in result:
|
||||||
self.assertEqual(hjob.hash_url.hexdigest(), result["url"])
|
self.assertEqual(hjob.hash_url.hexdigest(), result["url"])
|
||||||
@@ -31,7 +34,7 @@ def generate_test(extr):
|
|||||||
print(extr.__name__)
|
print(extr.__name__)
|
||||||
for url, result in extr.test:
|
for url, result in extr.test:
|
||||||
print(url)
|
print(url)
|
||||||
self.run_test(url, result)
|
self.run_test(extr, url, result)
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user