[tests] rework filters for extractor tests

CI incompatible tests will now only be skipped if tests are run in
a CI environment.
This commit is contained in:
Mike Fährmann
2018-03-13 13:11:10 +01:00
parent d6ef52897c
commit 4d74749496
2 changed files with 34 additions and 23 deletions

View File

@@ -15,9 +15,10 @@ class PowermangaChapterExtractor(foolslide.FoolslideChapterExtractor):
"""Extractor for manga-chapters from powermanga.org"""
category = "powermanga"
pattern = foolslide.chapter_pattern(r"read(?:er)?\.powermanga\.org")
test = [("https://read.powermanga.org/read/one_piece/en/0/803/page/1", {
"url": "e6179c1565068f99180620281f86bdd25be166b4",
"keyword": "224cab1f946d976ddbe4ef88fa1c02303699910b",
test = [(("https://read.powermanga.org"
"/read/one_piece_digital_colour_comics/en/0/75/"), {
"url": "854c5817f8f767e1bccd05fa9d58ffb5a4b09384",
"keyword": "9bf211d435060d1e38d3d13e4aaaa5a87381bfad",
})]
@@ -25,7 +26,8 @@ class PowermangaMangaExtractor(foolslide.FoolslideMangaExtractor):
"""Extractor for manga from powermanga.org"""
category = "powermanga"
pattern = foolslide.manga_pattern(r"read\.powermanga\.org")
test = [("https://read.powermanga.org/series/one_piece/", {
test = [(("https://read.powermanga.org"
"/series/one_piece_digital_colour_comics/"), {
"count": ">= 1",
"keyword": {
"chapter": int,
@@ -34,7 +36,7 @@ class PowermangaMangaExtractor(foolslide.FoolslideMangaExtractor):
"group": "PowerManga",
"lang": "en",
"language": "English",
"manga": "One Piece",
"manga": "One Piece Digital Colour Comics",
"title": str,
"volume": int,
},

View File

@@ -7,22 +7,21 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
import os
import sys
import unittest
from gallery_dl import extractor, job, config, exception
SKIP = {
# don't work on travis-ci
# these don't work on travis-ci
TRAVIS_SKIP = {
"exhentai", "kissmanga", "mangafox", "dynastyscans", "nijie",
"archivedmoe", "archiveofsins", "thebarchive",
}
# temporary issues
"imgcandy",
"imgchili",
"imgtrex",
"powermanga",
"puremashiro",
# temporary issues, etc.
BROKEN = {
"puremashiro", # online reader down
}
@@ -134,20 +133,30 @@ def generate_tests():
# enable selective testing for direct calls
if __name__ == '__main__' and len(sys.argv) > 1:
if sys.argv[1].lower() == "all":
extractors = extractor.extractors()
fltr = lambda c, bc: True # noqa: E731
elif sys.argv[1].lower() == "broken":
fltr = lambda c, bc: c in BROKEN # noqa: E731
else:
extractors = [
extr for extr in extractor.extractors()
if extr.category in sys.argv or
hasattr(extr, "basecategory") and extr.basecategory in sys.argv
]
argv = sys.argv[1:]
fltr = lambda c, bc: c in argv or bc in argv # noqa: E731
del sys.argv[1:]
else:
extractors = [
extr for extr in extractor.extractors()
if extr.category not in SKIP
]
skip = BROKEN.copy()
if "CI" in os.environ and "TRAVIS" in os.environ:
skip |= TRAVIS_SKIP
print("skipping:", ", ".join(skip))
fltr = lambda c, bc: c not in skip # noqa: E731
# filter available extractor classes
extractors = [
extr for extr in extractor.extractors()
if fltr(
extr.category,
extr.basecategory if hasattr(extr, "basecategory") else None
)
]
# add 'test_...' methods to TestExtractors
for extr in extractors:
if not hasattr(extr, "test") or not extr.test:
continue