1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-24 19:52:32 +01:00

[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
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

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()