From fd67eb9cd4b22ac4301530106047a3da96eaacb6 Mon Sep 17 00:00:00 2001 From: spl0k Date: Tue, 16 Jan 2018 23:16:13 +0100 Subject: [PATCH] Fixed DeprecationWarnings --- supysonic/api/media.py | 4 ++-- supysonic/lastfm.py | 4 ++-- tests/base/test_db.py | 15 ++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/supysonic/api/media.py b/supysonic/api/media.py index 3d62baf..9091fa9 100644 --- a/supysonic/api/media.py +++ b/supysonic/api/media.py @@ -196,7 +196,7 @@ def lyrics(): except UnicodeError: # Lyrics file couldn't be decoded. Rather than displaying an error, try with the potential next files or # return no lyrics. Log it anyway. - app.logger.warn('Unsupported encoding for lyrics file ' + lyrics_path) + app.logger.warning('Unsupported encoding for lyrics file ' + lyrics_path) continue return request.formatter(dict(lyrics = dict( @@ -217,7 +217,7 @@ def lyrics(): _value_ = root.find('cl:Lyric', namespaces = ns).text ))) except requests.exceptions.RequestException as e: - app.logger.warn('Error while requesting the ChartLyrics API: ' + str(e)) + app.logger.warning('Error while requesting the ChartLyrics API: ' + str(e)) return request.formatter(dict(lyrics = dict())) diff --git a/supysonic/lastfm.py b/supysonic/lastfm.py index 3a0359d..16e1882 100644 --- a/supysonic/lastfm.py +++ b/supysonic/lastfm.py @@ -92,14 +92,14 @@ class LastFm: else: r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs) except requests.exceptions.RequestException as e: - self.__logger.warn('Error while connecting to LastFM: ' + str(e)) + self.__logger.warning('Error while connecting to LastFM: ' + str(e)) return None json = r.json() if 'error' in json: if json['error'] in (9, '9'): self.__user.lastfm_status = False - self.__logger.warn('LastFM error %i: %s' % (json['error'], json['message'])) + self.__logger.warning('LastFM error %i: %s' % (json['error'], json['message'])) return json diff --git a/tests/base/test_db.py b/tests/base/test_db.py index 36a9896..5893e6d 100644 --- a/tests/base/test_db.py +++ b/tests/base/test_db.py @@ -24,6 +24,11 @@ class DbTestCase(unittest.TestCase): def setUp(self): db.init_database('sqlite:', True) + try: + self.assertRegex + except AttributeError: + self.assertRegex = self.assertRegexpMatches + def tearDown(self): db.release_database() @@ -118,7 +123,7 @@ class DbTestCase(unittest.TestCase): self.assertTrue(root['isDir']) self.assertEqual(root['title'], 'Root folder') self.assertEqual(root['album'], 'Root folder') - self.assertRegexpMatches(root['created'], date_regex) + self.assertRegex(root['created'], date_regex) child = child_folder.as_subsonic_child(user) self.assertIn('parent', child) @@ -153,7 +158,7 @@ class DbTestCase(unittest.TestCase): self.assertIn('starred', root) self.assertIn('userRating', root) self.assertIn('averageRating', root) - self.assertRegexpMatches(root['starred'], date_regex) + self.assertRegex(root['starred'], date_regex) self.assertEqual(root['userRating'], 2) self.assertEqual(root['averageRating'], 3.5) @@ -176,7 +181,7 @@ class DbTestCase(unittest.TestCase): self.assertIn('starred', artist_dict) self.assertEqual(artist_dict['name'], 'Test Artist') self.assertEqual(artist_dict['albumCount'], 0) - self.assertRegexpMatches(artist_dict['starred'], date_regex) + self.assertRegex(artist_dict['starred'], date_regex) db.Album(name = 'Test Artist', artist = artist) # self-titled db.Album(name = 'The Album After The First One', artist = artist) @@ -215,8 +220,8 @@ class DbTestCase(unittest.TestCase): self.assertEqual(album_dict['artistId'], str(artist.id)) self.assertEqual(album_dict['songCount'], 2) self.assertEqual(album_dict['duration'], 8) - self.assertRegexpMatches(album_dict['created'], date_regex) - self.assertRegexpMatches(album_dict['starred'], date_regex) + self.assertRegex(album_dict['created'], date_regex) + self.assertRegex(album_dict['starred'], date_regex) @db_session def test_track(self):