From 255d08b79ed7aa18304d1a78badb97ff94cbae17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 28 Jul 2023 16:58:16 +0200 Subject: [PATCH] add test for 'Extractor.initialize()' (#4359) --- gallery_dl/extractor/mangahere.py | 3 +-- gallery_dl/extractor/tumblr.py | 7 +++++-- test/test_extractor.py | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/mangahere.py b/gallery_dl/extractor/mangahere.py index 97c26d47..745231b1 100644 --- a/gallery_dl/extractor/mangahere.py +++ b/gallery_dl/extractor/mangahere.py @@ -114,8 +114,7 @@ class MangahereMangaExtractor(MangahereBase, MangaExtractor): ("https://m.mangahere.co/manga/aria/"), ) - def __init__(self, match): - MangaExtractor.__init__(self, match) + def _init(self): self.cookies.set("isAdult", "1", domain="www.mangahere.cc") def chapters(self, page): diff --git a/gallery_dl/extractor/tumblr.py b/gallery_dl/extractor/tumblr.py index 12ea39f8..9adc3ab1 100644 --- a/gallery_dl/extractor/tumblr.py +++ b/gallery_dl/extractor/tumblr.py @@ -442,10 +442,13 @@ class TumblrDayExtractor(TumblrExtractor): def __init__(self, match): TumblrExtractor.__init__(self, match) year, month, day = match.group(4).split("/") - self.date_min = ts = ( + self.date_min = ( # 719163 == date(1970, 1, 1).toordinal() 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): return self.api.posts(self.blog, {}) diff --git a/test/test_extractor.py b/test/test_extractor.py index 6516fa8f..e3286647 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -132,8 +132,16 @@ class TestExtractorModule(unittest.TestCase): else: 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): - """ensure docstring uniqueness""" + """Ensure docstring uniqueness""" for extr1 in extractor.extractors(): for extr2 in extractor.extractors(): if extr1 != extr2 and extr1.__doc__ and extr2.__doc__: