42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import tempfile
|
|
import unittest
|
|
import warnings
|
|
from pathlib import Path
|
|
|
|
|
|
class ExistingClientLoaderTests(unittest.TestCase):
|
|
def test_build_music_client_can_instantiate_qq_client_lazily(self):
|
|
from musicdl.modules import BuildMusicClient
|
|
|
|
with warnings.catch_warnings():
|
|
warnings.simplefilter("ignore", ResourceWarning)
|
|
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmpdir:
|
|
client = BuildMusicClient(
|
|
{
|
|
"type": "QQMusicClient",
|
|
"logger_handle": None,
|
|
"disable_print": True,
|
|
"work_dir": str(Path(tmpdir) / "outputs"),
|
|
"maintain_session": False,
|
|
"search_size_per_source": 1,
|
|
"search_size_per_page": 1,
|
|
"strict_limit_search_size_per_page": True,
|
|
}
|
|
)
|
|
|
|
self.assertEqual("QQMusicClient", client.source)
|
|
|
|
def test_default_download_source_modules_enable_postponed_annotations_for_python38(self):
|
|
source_dir = Path("musicdl/modules/sources")
|
|
for module_name in ("qq.py", "kuwo.py", "migu.py", "qianqian.py", "kugou.py", "netease.py"):
|
|
module_text = (source_dir / module_name).read_text(encoding="utf-8")
|
|
self.assertIn(
|
|
"from __future__ import annotations",
|
|
module_text,
|
|
msg=f"{module_name} should postpone annotation evaluation for Python 3.8 compatibility",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|