several changes to make travis build work

- fixed html.unescape not being available on Python3.3
- removed inconsistent test result
- added username/password pairs for authenticating extractors
pull/13/head
Mike Fährmann 8 years ago
parent cfe5bf732a
commit 00074a71d7
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -18,7 +18,6 @@ class InfinitychanThreadExtractor(chan.ChanThreadExtractor):
test = [("https://8ch.net/wh40k/res/1.html", { test = [("https://8ch.net/wh40k/res/1.html", {
"url": "9220c79950d3f9cdd2c0436e816aec6b8342fac1", "url": "9220c79950d3f9cdd2c0436e816aec6b8342fac1",
"keyword": "df5773339c5864c71b63fc26ca60ea7098b83cb1", "keyword": "df5773339c5864c71b63fc26ca60ea7098b83cb1",
"content": "0533b95bee50c616e3c1a8c50e4087e170cfd950",
})] })]
api_url = "https://8ch.net/{board}/res/{thread}.json" api_url = "https://8ch.net/{board}/res/{thread}.json"
file_url = "https://media.8ch.net/{board}/src/{tim}{ext}" file_url = "https://media.8ch.net/{board}/src/{tim}{ext}"

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015, 2016 Mike Fährmann # Copyright 2015-2017 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
@ -113,4 +113,8 @@ else:
unquote = urllib.parse.unquote unquote = urllib.parse.unquote
try:
unescape = html.unescape unescape = html.unescape
except AttributeError:
import html.parse
unescape = html.parse.HTMLParser().unescape

@ -7,6 +7,7 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
import sys
import unittest import unittest
from gallery_dl import extractor, job, config from gallery_dl import extractor, job, config
@ -14,8 +15,13 @@ from gallery_dl import extractor, job, config
class TestExtractors(unittest.TestCase): class TestExtractors(unittest.TestCase):
def setUp(self): def setUp(self):
config.load() name = "gallerydl"
email = "gallerydl@openaliasbox.org"
config.set(("cache", "file"), ":memory:") config.set(("cache", "file"), ":memory:")
config.set(("username",), name)
config.set(("password",), name)
config.set(("extractor", "nijie", "username"), email)
config.set(("extractor", "seiga", "username"), email)
def _run_test(self, extr, url, result): def _run_test(self, extr, url, result):
hjob = job.HashJob(url, "content" in result) hjob = job.HashJob(url, "content" in result)
@ -40,10 +46,19 @@ def _generate_test(extr, tcase):
self._run_test(extr, url, result) self._run_test(extr, url, result)
return test return test
# enable selective testing for direct calls
extractors = extractor.extractors()
if __name__ == '__main__' and len(sys.argv) > 1:
print(sys.argv)
extractors = [
extr for extr in extractors
if extr.category in sys.argv
]
del sys.argv[1:]
for extr in extractor.extractors(): skip = ("exhentai", "kissmanga")
# disable extractors that require authentication for now for extr in extractors:
if hasattr(extr, "login"): if extr.category in skip:
continue continue
if hasattr(extr, "test") and extr.test: if hasattr(extr, "test") and extr.test:
name = "test_" + extr.__name__ + "_" name = "test_" + extr.__name__ + "_"

Loading…
Cancel
Save