From d50c312ff0352e00cff3ea9ba384de53449de2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 29 Jul 2023 13:48:31 +0200 Subject: [PATCH] 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 --- test/test_extractor.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_extractor.py b/test/test_extractor.py index 67d55b06..f8bed133 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -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():