diff --git a/poetry.lock b/poetry.lock index 4e73d6875..fb00f0b08 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1943,6 +1943,20 @@ dev = ["changelogd", "nox"] docs = ["changelogd", "furo", "sphinx", "sphinx-autodoc-typehints", "sphinxcontrib-napoleon"] test = ["Pygments (>=2.0)", "anyio", "coverage", "docutils (>=0.12)", "pytest (>=4.0)", "pytest-asyncio (>=0.15.1)", "pytest-rerunfailures", "pytest-timeout"] +[[package]] +name = "pytest-vcr-delete-on-fail" +version = "2.0.1" +description = "A pytest plugin that automates vcrpy cassettes deletion on test failure." +optional = false +python-versions = ">=3.8.1,<4.0.0" +files = [ + {file = "pytest_vcr_delete_on_fail-2.0.1-py3-none-any.whl", hash = "sha256:fe4fbd0067da3d7f33b24e169344c03bfdf0001a604ece8a55b1b794e92a410b"}, + {file = "pytest_vcr_delete_on_fail-2.0.1.tar.gz", hash = "sha256:7f07e079615cfdcda01e8d24367b6b2a89402e094e1f7439ff3ac35b59807200"}, +] + +[package.dependencies] +pytest = ">=8.0.0,<9.0.0" + [[package]] name = "python-dateutil" version = "2.9.0.post0" diff --git a/pyproject.toml b/pyproject.toml index 5d769ade5..ceb9a5ec0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,6 +83,7 @@ mkdocs-literate-nav = "^0.6.0" mkdocs-section-index = "^0.3.5" vcrpy = "^6.0.1" pytest-recording = "^0.13.1" +pytest-vcr-delete-on-fail = {version = "^2.0.1", python = "^3.8.1"} [tool.poetry.scripts] spotdl = "spotdl:console_entry_point" diff --git a/tests/console/test_entry_point.py b/tests/console/test_entry_point.py index 9f815ca00..fea2152e1 100644 --- a/tests/console/test_entry_point.py +++ b/tests/console/test_entry_point.py @@ -84,6 +84,7 @@ def test_download_song(capsys, monkeypatch, tmpdir): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_preload_song(capsys, monkeypatch, tmpdir): """ This test checks if the song is preloaded correctly. diff --git a/tests/providers/audio/test_youtube.py b/tests/providers/audio/test_youtube.py index 67af0e5a5..5be94b33d 100644 --- a/tests/providers/audio/test_youtube.py +++ b/tests/providers/audio/test_youtube.py @@ -5,6 +5,7 @@ @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_yt_search(): provider = YouTube() @@ -43,6 +44,7 @@ def test_yt_search(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_yt_get_results(): provider = YouTube() diff --git a/tests/providers/audio/test_ytmusic.py b/tests/providers/audio/test_ytmusic.py index c5a6fe826..31d27c64d 100644 --- a/tests/providers/audio/test_ytmusic.py +++ b/tests/providers/audio/test_ytmusic.py @@ -5,6 +5,7 @@ @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_ytm_search(): provider = YouTubeMusic() @@ -43,6 +44,7 @@ def test_ytm_search(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_ytm_get_results(): provider = YouTubeMusic() diff --git a/tests/providers/lyrics/test_azlyrics.py b/tests/providers/lyrics/test_azlyrics.py index cca8b678e..fc2d20a55 100644 --- a/tests/providers/lyrics/test_azlyrics.py +++ b/tests/providers/lyrics/test_azlyrics.py @@ -7,6 +7,7 @@ # @pytest.mark.vcr() +# @pytest.mark.vcr_delete_on_fail # def test_get_azlyrics_lyrics(): # azlyrics = AzLyrics() diff --git a/tests/providers/lyrics/test_genius.py b/tests/providers/lyrics/test_genius.py index 8a7fe4515..e69a1e6db 100644 --- a/tests/providers/lyrics/test_genius.py +++ b/tests/providers/lyrics/test_genius.py @@ -7,6 +7,7 @@ # @pytest.mark.vcr() +# @pytest.mark.vcr_delete_on_fail # def test_get_genius_lyrics(): # genius = Genius() diff --git a/tests/providers/lyrics/test_musixmatch.py b/tests/providers/lyrics/test_musixmatch.py index 0eb359bbb..34aec8b56 100644 --- a/tests/providers/lyrics/test_musixmatch.py +++ b/tests/providers/lyrics/test_musixmatch.py @@ -4,6 +4,7 @@ # @pytest.mark.vcr() +# @pytest.mark.vcr_delete_on_fail # def test_get_musixmatch_lyrics(): # musixmatch = MusixMatch() diff --git a/tests/test_init.py b/tests/test_init.py index 06ca57ecf..f7cc6d172 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -19,6 +19,7 @@ def setup(tmp_path, monkeypatch): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_get_urls(monkeypatch): """ Tests if spotdl can be initialized correctly. @@ -50,6 +51,7 @@ def test_get_urls(monkeypatch): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_download(setup, monkeypatch, tmpdir): """ Tests if spotdl can be initialized correctly. diff --git a/tests/test_matching.py b/tests/test_matching.py index 9de16882a..e94336d0b 100644 --- a/tests/test_matching.py +++ b/tests/test_matching.py @@ -403,6 +403,7 @@ ], ) @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_ytmusic_matching(monkeypatch, query, expected, capsys): monkeypatch.setattr(SpotifyClient, "init", new_initialize) diff --git a/tests/types/test_album.py b/tests/types/test_album.py index 7a9b435e3..d0601fb4f 100644 --- a/tests/types/test_album.py +++ b/tests/types/test_album.py @@ -24,6 +24,7 @@ def test_album_wrong_init(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_album_from_url(): """ Test if Album class can be initialized from url. @@ -38,6 +39,7 @@ def test_album_from_url(): # @pytest.mark.vcr() +# @pytest.mark.vcr_delete_on_fail # def test_album_from_string(): # """ # Test if Album class can be initialized from string. @@ -52,6 +54,7 @@ def test_album_from_url(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_album_length(): """ Tests if Album.length works correctly. diff --git a/tests/types/test_artist.py b/tests/types/test_artist.py index 302202174..7dc41f32e 100644 --- a/tests/types/test_artist.py +++ b/tests/types/test_artist.py @@ -42,6 +42,7 @@ def test_artist_wrong_init(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_artist_from_url(): """ Test if Artist class can be initialized from url. @@ -56,6 +57,7 @@ def test_artist_from_url(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_artist_from_string(): """ Test if Artist class can be initialized from string. diff --git a/tests/types/test_playlist.py b/tests/types/test_playlist.py index a5e0abd28..34514bfeb 100644 --- a/tests/types/test_playlist.py +++ b/tests/types/test_playlist.py @@ -42,6 +42,7 @@ def test_playlist_wrong_initget_results(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_playlist_from_url(): """ Tests if Playlist.from_url() works correctly. @@ -58,6 +59,7 @@ def test_playlist_from_url(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_playlist_from_string(): """ Test if Playlist class can be initialized from string. @@ -71,6 +73,7 @@ def test_playlist_from_string(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_playlist_length(): """ Tests if Playlist.length works correctly. diff --git a/tests/types/test_song.py b/tests/types/test_song.py index e7421e032..37dd1edd2 100644 --- a/tests/types/test_song.py +++ b/tests/types/test_song.py @@ -78,6 +78,7 @@ def test_song_wrong_init(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_song_from_url(): """ Tests if Song.from_url() works correctly. @@ -109,6 +110,7 @@ def test_song_from_url(): # @pytest.mark.vcr() +# @pytest.mark.vcr_delete_on_fail # def test_song_from_search_term(): # """ # Tests if Song.from_search_term() works correctly. diff --git a/tests/utils/test_ffmpeg.py b/tests/utils/test_ffmpeg.py index f9735e656..98c543193 100644 --- a/tests/utils/test_ffmpeg.py +++ b/tests/utils/test_ffmpeg.py @@ -115,6 +115,7 @@ def test_download_ffmpeg(monkeypatch, tmpdir): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_convert(tmpdir, monkeypatch): """ Test convert function. diff --git a/tests/utils/test_github.py b/tests/utils/test_github.py index 394142d4b..7bd73955c 100644 --- a/tests/utils/test_github.py +++ b/tests/utils/test_github.py @@ -11,6 +11,7 @@ @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_get_status(): status = get_status("master", "dev", "spotdl/spotify-downloader") @@ -18,12 +19,14 @@ def test_get_status(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_get_status_fail(): with pytest.raises(RuntimeError): get_status("master", "dev", "spotdl/spotify-downloader-fail") @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_check_for_updates(monkeypatch): monkeypatch.setattr(_version, "__version__", "3.9.4") message = check_for_updates("spotdl/spotify-downloader") @@ -32,6 +35,7 @@ def test_check_for_updates(monkeypatch): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_check_for_updates_fail(monkeypatch): monkeypatch.setattr(_version, "__version__", "3.9.4") with pytest.raises(RuntimeError): @@ -39,6 +43,7 @@ def test_check_for_updates_fail(monkeypatch): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_create_github_url(): url = create_github_url(WEB_APP_URL) @@ -46,6 +51,7 @@ def test_create_github_url(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_download_github_dir(tmpdir, monkeypatch): monkeypatch.chdir(tmpdir) download_github_dir(WEB_APP_URL, False) diff --git a/tests/utils/test_m3u.py b/tests/utils/test_m3u.py index 7e9219821..256c9688e 100644 --- a/tests/utils/test_m3u.py +++ b/tests/utils/test_m3u.py @@ -7,6 +7,7 @@ @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_create_m3u_content(): playlist = Playlist.from_url(PLAYLIST) content = create_m3u_content( @@ -19,6 +20,7 @@ def test_create_m3u_content(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_create_m3u_file(tmpdir, monkeypatch): monkeypatch.chdir(tmpdir) playlist = Playlist.from_url(PLAYLIST) diff --git a/tests/utils/test_metadata.py b/tests/utils/test_metadata.py index 4f7d5db89..ae7c4ef13 100644 --- a/tests/utils/test_metadata.py +++ b/tests/utils/test_metadata.py @@ -21,6 +21,7 @@ ], ) @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_embed_metadata(tmpdir, monkeypatch, output_format): """ Test convert function. diff --git a/tests/utils/test_search.py b/tests/utils/test_search.py index 28148a88f..56e760d3a 100644 --- a/tests/utils/test_search.py +++ b/tests/utils/test_search.py @@ -19,6 +19,7 @@ @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_song(): songs = parse_query(SONG) @@ -28,6 +29,7 @@ def test_parse_song(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_album(): songs = parse_query(ALBUM) @@ -36,6 +38,7 @@ def test_parse_album(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_yt_link(): songs = parse_query(YT) @@ -45,6 +48,7 @@ def test_parse_yt_link(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_artist(): songs = parse_query(ARTIST) @@ -52,6 +56,7 @@ def test_parse_artist(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_album_search(): songs = parse_query(ALBUM_SEARCH) @@ -59,12 +64,14 @@ def test_parse_album_search(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_saved(): with pytest.raises(SavedError): parse_query(SAVED) @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_parse_query(): songs = parse_query(QUERY) @@ -72,6 +79,7 @@ def test_parse_query(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_get_search_results(): results = get_search_results("test") assert len(results) > 1 @@ -87,6 +95,7 @@ def test_create_empty_song(): @pytest.mark.vcr() +@pytest.mark.vcr_delete_on_fail def test_get_simple_songs(): songs = get_simple_songs(QUERY) assert len(songs) > 1