prevent test failure when there's no 'ytdl' module (#4364)
split of ytdl into its own test function and skip it when there's an ImportError similar to test_ytdl.py
This commit is contained in:
@@ -135,12 +135,25 @@ class TestExtractorModule(unittest.TestCase):
|
||||
def test_init(self):
|
||||
"""Test for exceptions in Extractor.initialize(()"""
|
||||
for cls in extractor.extractors():
|
||||
if cls.category == "ytdl":
|
||||
continue
|
||||
for test in cls._get_tests():
|
||||
extr = cls.from_url(test[0])
|
||||
extr.initialize()
|
||||
extr.finalize()
|
||||
break
|
||||
|
||||
def test_init_ytdl(self):
|
||||
try:
|
||||
extr = extractor.find("ytdl:")
|
||||
extr.initialize()
|
||||
extr.finalize()
|
||||
except ImportError as exc:
|
||||
if exc.name in ("youtube_dl", "yt_dlp"):
|
||||
raise unittest.SkipTest("cannot import module '{}'".format(
|
||||
exc.name))
|
||||
raise
|
||||
|
||||
def test_docstrings(self):
|
||||
"""Ensure docstring uniqueness"""
|
||||
for extr1 in extractor.extractors():
|
||||
|
||||
Reference in New Issue
Block a user