diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f37251..a36d432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Extract username from session via new `SessionKeyGenerator.get_web_auth_session_key_username` ([#290]) +### Deprecated + +* `User.get_artist_tracks` ([#298]) + ## [3.0.0] - 2019-01-01 ### Added * This changelog file ([#273]) @@ -31,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [Unreleased]: https://github.com/pylast/pylast/compare/v3.0.0...HEAD [3.0.0]: https://github.com/pylast/pylast/compare/2.4.0...3.0.0 [2.4.0]: https://github.com/pylast/pylast/compare/2.3.0...2.4.0 +[#298]: https://github.com/pylast/pylast/issues/298 [#290]: https://github.com/pylast/pylast/pull/290 [#265]: https://github.com/pylast/pylast/issues/265 [#273]: https://github.com/pylast/pylast/issues/273 diff --git a/pylast/__init__.py b/pylast/__init__.py index 5b839c9..1cd1a2e 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -20,18 +20,19 @@ # # https://github.com/pylast/pylast -from xml.dom import minidom, Node import collections import hashlib +import html.entities import logging import shelve import ssl import sys import tempfile import time +import warnings import xml.dom -import html.entities from http.client import HTTPSConnection +from xml.dom import Node, minidom from . import version @@ -2236,6 +2237,13 @@ class User(_BaseObject, _Chartable): # Not implemented: # "Can be limited to specific timeranges, defaults to all time." + warnings.warn( + "User.get_artist_tracks is deprecated and will be removed in a future " + "version: https://github.com/pylast/pylast/issues/298", + DeprecationWarning, + stacklevel=2, + ) + params = self._get_params() params["artist"] = artist diff --git a/tests/test_album.py b/tests/test_album.py index a2836fd..c855d48 100755 --- a/tests/test_album.py +++ b/tests/test_album.py @@ -3,6 +3,7 @@ Integration (not unit) tests for pylast.py """ import unittest +import warnings import pylast @@ -44,7 +45,9 @@ class TestPyLastAlbum(TestPyLastWithLastFm): lastfm_user = self.network.get_user(self.username) # Act - track = lastfm_user.get_artist_tracks(artist="Test Artist")[0] + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + track = lastfm_user.get_artist_tracks(artist="Test Artist")[0] # Assert self.assertTrue(hasattr(track, "album")) diff --git a/tests/test_user.py b/tests/test_user.py index 1e7c76d..bd019ea 100755 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -4,6 +4,7 @@ Integration (not unit) tests for pylast.py """ import os import unittest +import warnings import pylast @@ -186,9 +187,11 @@ class TestPyLastUser(TestPyLastWithLastFm): lastfm_user = self.network.get_authenticated_user() # Act - result1 = lastfm_user.get_artist_tracks("Test Artist", cacheable=False) - result2 = lastfm_user.get_artist_tracks("Test Artist", cacheable=True) - result3 = lastfm_user.get_artist_tracks("Test Artist") + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + result1 = lastfm_user.get_artist_tracks("Test Artist", cacheable=False) + result2 = lastfm_user.get_artist_tracks("Test Artist", cacheable=True) + result3 = lastfm_user.get_artist_tracks("Test Artist") # Assert self.helper_validate_results(result1, result2, result3)