[tests] fix bug when running tests in a certain order

test_ytdl -> test_downloader -> test_extractor
would cause a test failure in Python <3.6 related to youtube_dl imports
This commit is contained in:
Mike Fährmann
2024-08-31 09:05:07 +02:00
parent 60b655429f
commit 510ca36b35

View File

@@ -45,11 +45,15 @@ class TestDownloaderModule(unittest.TestCase):
@classmethod
def setUpClass(cls):
# allow import of ytdl downloader module without youtube_dl installed
cls._orig_ytdl = sys.modules.get("youtube_dl")
sys.modules["youtube_dl"] = MagicMock()
@classmethod
def tearDownClass(cls):
del sys.modules["youtube_dl"]
if cls._orig_ytdl:
sys.modules["youtube_dl"] = cls._orig_ytdl
else:
del sys.modules["youtube_dl"]
def tearDown(self):
downloader._cache.clear()