diff --git a/tests/console/test_entry_point.py b/tests/console/test_entry_point.py index 3f7dffba0..38e356774 100644 --- a/tests/console/test_entry_point.py +++ b/tests/console/test_entry_point.py @@ -52,7 +52,7 @@ def test_show_version(capsys, monkeypatch, argument): assert re.match(r"\d{1,2}\.\d{1,2}\.\d{1,3}", out) is not None -def test_download_song(capsys, monkeypatch, tmpdir): +def test_download_song(capsys, monkeypatch, tmp_path): """ This test checks if the song is downloaded correctly """ @@ -73,7 +73,7 @@ def test_download_song(capsys, monkeypatch, tmpdir): monkeypatch.setattr(sys, "argv", cli_args) monkeypatch.setattr(SpotifyClient, "init", new_initialize) - monkeypatch.chdir(tmpdir) + monkeypatch.chdir(tmp_path) console_entry_point() @@ -82,7 +82,7 @@ def test_download_song(capsys, monkeypatch, tmpdir): assert "Downloaded" in out -def test_preload_song(capsys, monkeypatch, tmpdir): +def test_preload_song(capsys, monkeypatch, tmp_path): """ This test checks if the song is preloaded correctly. """ @@ -106,7 +106,7 @@ def test_preload_song(capsys, monkeypatch, tmpdir): monkeypatch.setattr(sys, "argv", cli_args) monkeypatch.setattr(SpotifyClient, "init", new_initialize) - monkeypatch.chdir(tmpdir) + monkeypatch.chdir(tmp_path) console_entry_point() diff --git a/tests/test_init.py b/tests/test_init.py index fad1f8f06..994299961 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -48,12 +48,12 @@ def test_get_urls(monkeypatch): assert len(urls) == 1 -def test_download(setup, monkeypatch, tmpdir): +def test_download(setup, monkeypatch, tmp_path): """ Tests if spotdl can be initialized correctly. """ - monkeypatch.chdir(tmpdir) + monkeypatch.chdir(tmp_path) monkeypatch.setattr(SpotifyClient, "init", new_initialize) diff --git a/tests/utils/test_archive.py b/tests/utils/test_archive.py index 07c75054b..e9ed024d9 100644 --- a/tests/utils/test_archive.py +++ b/tests/utils/test_archive.py @@ -3,11 +3,11 @@ from spotdl.utils.archive import Archive -def test_load_archive(tmpdir, monkeypatch): - monkeypatch.chdir(tmpdir) +def test_load_archive(tmp_path, monkeypatch): + monkeypatch.chdir(tmp_path) archive1 = Archive(["a", "b", "c"]) assert archive1.save("archive.txt") is True - assert tmpdir.join("archive.txt").isfile() is True + assert tmp_path.join("archive.txt").isfile() is True archive2 = Archive() assert archive2.load("archive.txt") is True assert len(archive2) == len(archive1) diff --git a/tests/utils/test_config.py b/tests/utils/test_config.py index 0884fcbfc..1de1904d0 100644 --- a/tests/utils/test_config.py +++ b/tests/utils/test_config.py @@ -8,10 +8,10 @@ @pytest.fixture() -def setup(tmpdir, monkeypatch): - monkeypatch.setattr(os.path, "expanduser", lambda *_: tmpdir) +def setup(tmp_path, monkeypatch): + monkeypatch.setattr(os.path, "expanduser", lambda *_: tmp_path) data = SimpleNamespace() - data.directory = tmpdir + data.directory = tmp_path yield data diff --git a/tests/utils/test_ffmpeg.py b/tests/utils/test_ffmpeg.py index 84b210fd9..3251e3327 100644 --- a/tests/utils/test_ffmpeg.py +++ b/tests/utils/test_ffmpeg.py @@ -101,23 +101,23 @@ def test_get_local_ffmpeg(monkeypatch): assert str(local_ffmpeg).endswith("ffmpeg.exe") -def test_download_ffmpeg(monkeypatch, tmpdir): +def test_download_ffmpeg(monkeypatch, tmp_path): """ Test download_ffmpeg function. """ - monkeypatch.setattr(spotdl.utils.ffmpeg, "get_spotdl_path", lambda *_: tmpdir) + monkeypatch.setattr(spotdl.utils.ffmpeg, "get_spotdl_path", lambda *_: tmp_path) assert download_ffmpeg() is not None -def test_convert(tmpdir, monkeypatch): +def test_convert(tmp_path, monkeypatch): """ Test convert function. """ - monkeypatch.chdir(tmpdir) - monkeypatch.setattr(spotdl.utils.ffmpeg, "get_spotdl_path", lambda *_: tmpdir) + monkeypatch.chdir(tmp_path) + monkeypatch.setattr(spotdl.utils.ffmpeg, "get_spotdl_path", lambda *_: tmp_path) yt = YoutubeDL( { @@ -134,12 +134,12 @@ def test_convert(tmpdir, monkeypatch): assert convert( input_file=(download_info["url"], download_info["ext"]), - output_file=Path(tmpdir, "test.mp3"), + output_file=Path(tmp_path, "test.mp3"), ) == (True, None) assert convert( - input_file=Path(tmpdir, "test.mp3"), - output_file=Path(tmpdir, "test.m4a"), + input_file=Path(tmp_path, "test.mp3"), + output_file=Path(tmp_path, "test.m4a"), output_format="m4a", bitrate="320K", ) == (True, None) diff --git a/tests/utils/test_github.py b/tests/utils/test_github.py index 394142d4b..58f6590ca 100644 --- a/tests/utils/test_github.py +++ b/tests/utils/test_github.py @@ -46,9 +46,9 @@ def test_create_github_url(): @pytest.mark.vcr() -def test_download_github_dir(tmpdir, monkeypatch): - monkeypatch.chdir(tmpdir) +def test_download_github_dir(tmp_path, monkeypatch): + monkeypatch.chdir(tmp_path) download_github_dir(WEB_APP_URL, False) - download_dir = tmpdir.listdir()[0] + download_dir = tmp_path.listdir()[0] assert download_dir.isdir() is True assert download_dir.join("index.html").isfile() is True diff --git a/tests/utils/test_m3u.py b/tests/utils/test_m3u.py index c74619fd6..3faac3cc8 100644 --- a/tests/utils/test_m3u.py +++ b/tests/utils/test_m3u.py @@ -18,8 +18,8 @@ def test_create_m3u_content(): assert content.split("\n")[1].startswith("#EXTINF:") assert content.split("\n")[2].endswith(".mp3") -def test_create_m3u_file(tmpdir, monkeypatch): - monkeypatch.chdir(tmpdir) +def test_create_m3u_file(tmp_path, monkeypatch): + monkeypatch.chdir(tmp_path) playlist = Playlist.from_url(PLAYLIST) create_m3u_file("test.m3u", playlist.songs, "", "mp3") - assert tmpdir.join("test.m3u").isfile() is True + assert tmp_path.join("test.m3u").isfile() is True diff --git a/tests/utils/test_metadata.py b/tests/utils/test_metadata.py index 083bf7fb2..855d87fc7 100644 --- a/tests/utils/test_metadata.py +++ b/tests/utils/test_metadata.py @@ -20,13 +20,13 @@ "m4a", ], ) -def test_embed_metadata(tmpdir, monkeypatch, output_format): +def test_embed_metadata(tmp_path, monkeypatch, output_format): """ Test convert function. """ - monkeypatch.chdir(tmpdir) - monkeypatch.setattr(spotdl.utils.ffmpeg, "get_spotdl_path", lambda *_: tmpdir) + monkeypatch.chdir(tmp_path) + monkeypatch.setattr(spotdl.utils.ffmpeg, "get_spotdl_path", lambda *_: tmp_path) youtube = YoutubeDL( { @@ -67,7 +67,7 @@ def test_embed_metadata(tmpdir, monkeypatch, output_format): } song = Song.from_dict(song_obj) - output_file = Path(tmpdir / f"test.{output_format}") + output_file = Path(tmp_path / f"test.{output_format}") assert download_info is not None assert convert(