From 510ca36b3534fea739d57eb7310fa53a38c847f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 31 Aug 2024 09:05:07 +0200 Subject: [PATCH] [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 --- test/test_downloader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_downloader.py b/test/test_downloader.py index f88b2c0d..35cccc40 100644 --- a/test/test_downloader.py +++ b/test/test_downloader.py @@ -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()