From 00074a71d7bb87ce3cc537a5bad6672178e7a58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 10 Jan 2017 13:41:00 +0100 Subject: [PATCH] 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 --- gallery_dl/extractor/8chan.py | 1 - gallery_dl/text.py | 8 ++++++-- test/test_extractors.py | 25 ++++++++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/gallery_dl/extractor/8chan.py b/gallery_dl/extractor/8chan.py index dcd69737..e5797bc5 100644 --- a/gallery_dl/extractor/8chan.py +++ b/gallery_dl/extractor/8chan.py @@ -18,7 +18,6 @@ class InfinitychanThreadExtractor(chan.ChanThreadExtractor): test = [("https://8ch.net/wh40k/res/1.html", { "url": "9220c79950d3f9cdd2c0436e816aec6b8342fac1", "keyword": "df5773339c5864c71b63fc26ca60ea7098b83cb1", - "content": "0533b95bee50c616e3c1a8c50e4087e170cfd950", })] api_url = "https://8ch.net/{board}/res/{thread}.json" file_url = "https://media.8ch.net/{board}/src/{tim}{ext}" diff --git a/gallery_dl/text.py b/gallery_dl/text.py index aee48226..8b4ce91d 100644 --- a/gallery_dl/text.py +++ b/gallery_dl/text.py @@ -1,6 +1,6 @@ # -*- 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 # it under the terms of the GNU General Public License version 2 as @@ -113,4 +113,8 @@ else: unquote = urllib.parse.unquote -unescape = html.unescape +try: + unescape = html.unescape +except AttributeError: + import html.parse + unescape = html.parse.HTMLParser().unescape diff --git a/test/test_extractors.py b/test/test_extractors.py index 0e59899d..3847df45 100644 --- a/test/test_extractors.py +++ b/test/test_extractors.py @@ -7,6 +7,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +import sys import unittest from gallery_dl import extractor, job, config @@ -14,8 +15,13 @@ from gallery_dl import extractor, job, config class TestExtractors(unittest.TestCase): def setUp(self): - config.load() + name = "gallerydl" + email = "gallerydl@openaliasbox.org" 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): hjob = job.HashJob(url, "content" in result) @@ -40,10 +46,19 @@ def _generate_test(extr, tcase): self._run_test(extr, url, result) 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(): - # disable extractors that require authentication for now - if hasattr(extr, "login"): +skip = ("exhentai", "kissmanga") +for extr in extractors: + if extr.category in skip: continue if hasattr(extr, "test") and extr.test: name = "test_" + extr.__name__ + "_" @@ -51,7 +66,7 @@ for extr in extractor.extractors(): test = _generate_test(extr, tcase) test.__name__ = name + str(num) setattr(TestExtractors, test.__name__, test) -del test + del test if __name__ == '__main__': unittest.main(warnings='ignore')