add test for 'Extractor.initialize()' (#4359)

This commit is contained in:
Mike Fährmann
2023-07-28 16:58:16 +02:00
parent 2bcf0a4c49
commit 255d08b79e
3 changed files with 15 additions and 5 deletions

View File

@@ -114,8 +114,7 @@ class MangahereMangaExtractor(MangahereBase, MangaExtractor):
("https://m.mangahere.co/manga/aria/"), ("https://m.mangahere.co/manga/aria/"),
) )
def __init__(self, match): def _init(self):
MangaExtractor.__init__(self, match)
self.cookies.set("isAdult", "1", domain="www.mangahere.cc") self.cookies.set("isAdult", "1", domain="www.mangahere.cc")
def chapters(self, page): def chapters(self, page):

View File

@@ -442,10 +442,13 @@ class TumblrDayExtractor(TumblrExtractor):
def __init__(self, match): def __init__(self, match):
TumblrExtractor.__init__(self, match) TumblrExtractor.__init__(self, match)
year, month, day = match.group(4).split("/") year, month, day = match.group(4).split("/")
self.date_min = ts = ( self.date_min = (
# 719163 == date(1970, 1, 1).toordinal() # 719163 == date(1970, 1, 1).toordinal()
date(int(year), int(month), int(day)).toordinal() - 719163) * 86400 date(int(year), int(month), int(day)).toordinal() - 719163) * 86400
self.api.before = ts + 86400
def _init(self):
TumblrExtractor._init(self)
self.api.before = self.date_min + 86400
def posts(self): def posts(self):
return self.api.posts(self.blog, {}) return self.api.posts(self.blog, {})

View File

@@ -132,8 +132,16 @@ class TestExtractorModule(unittest.TestCase):
else: else:
self.assertIs(extr1, matches[0][1], url) self.assertIs(extr1, matches[0][1], url)
def test_init(self):
"""Test for exceptions in Extractor.initialize(()"""
for cls in extractor.extractors():
for test in cls._get_tests():
extr = cls.from_url(test[0])
extr.initialize()
break
def test_docstrings(self): def test_docstrings(self):
"""ensure docstring uniqueness""" """Ensure docstring uniqueness"""
for extr1 in extractor.extractors(): for extr1 in extractor.extractors():
for extr2 in extractor.extractors(): for extr2 in extractor.extractors():
if extr1 != extr2 and extr1.__doc__ and extr2.__doc__: if extr1 != extr2 and extr1.__doc__ and extr2.__doc__: