diff --git a/pylast/__init__.py b/pylast/__init__.py index 2fd0f12..32bf15c 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1398,7 +1398,7 @@ class _Opus(_BaseObject, _Taggable): return (a == b) and (c == d) def __ne__(self, other): - return not self.__eq__(other) + return not self == other def _get_params(self): return { @@ -1562,7 +1562,7 @@ class Artist(_BaseObject, _Taggable): return False def __ne__(self, other): - return not self.__eq__(other) + return not self == other def _get_params(self): return {self.ws_prefix: self.get_name()} @@ -1750,7 +1750,7 @@ class Country(_BaseObject): return self.get_name().lower() == other.get_name().lower() def __ne__(self, other): - return self.get_name() != other.get_name() + return not self == other def _get_params(self): # TODO can move to _BaseObject return {'country': self.get_name()} @@ -1878,7 +1878,7 @@ class Tag(_BaseObject, _Chartable): return self.get_name().lower() == other.get_name().lower() def __ne__(self, other): - return self.get_name().lower() != other.get_name().lower() + return not self == other def _get_params(self): return {self.ws_prefix: self.get_name()} @@ -2081,17 +2081,14 @@ class User(_BaseObject, _Chartable): def __str__(self): return self.get_name() - def __eq__(self, another): - if isinstance(another, User): - return self.get_name() == another.get_name() + def __eq__(self, other): + if isinstance(other, User): + return self.get_name() == other.get_name() else: return False - def __ne__(self, another): - if isinstance(another, User): - return self.get_name() != another.get_name() - else: - return True + def __ne__(self, other): + return not self == other def _get_params(self): return {self.ws_prefix: self.get_name()} diff --git a/tests/test_pylast_album.py b/tests/test_pylast_album.py index 53581a5..2c7f369 100755 --- a/tests/test_pylast_album.py +++ b/tests/test_pylast_album.py @@ -89,7 +89,7 @@ class TestPyLastAlbum(PyLastTestCase): album2 = pylast.Album("Test Artist", "Test Album", self.network) # Act / Assert - self.assertFalse(album1 == album2) + self.assertNotEqual(album1, album2) def test_album_ne_none_is_true(self): # Arrange @@ -97,7 +97,7 @@ class TestPyLastAlbum(PyLastTestCase): album2 = pylast.Album("Test Artist", "Test Album", self.network) # Act / Assert - self.assertTrue(album1 != album2) + self.assertNotEqual(album1, album2) def test_get_cover_image(self): # Arrange diff --git a/tests/test_pylast_artist.py b/tests/test_pylast_artist.py index 658f1d3..58612ea 100755 --- a/tests/test_pylast_artist.py +++ b/tests/test_pylast_artist.py @@ -251,7 +251,7 @@ class TestPyLastArtist(PyLastTestCase): # Assert self.assertIn("https", image) self.assertGreater(playcount, 1) - self.assertTrue(artist1 != artist2) + self.assertNotEqual(artist1, artist2) self.assertEqual(name.lower(), name_cap.lower()) self.assertEqual(url, "https://www.last.fm/music/radiohead") self.assertEqual(mbid, "a74b1b7f-71a5-4011-9441-d0b5e4122711") @@ -263,7 +263,7 @@ class TestPyLastArtist(PyLastTestCase): artist2 = pylast.Artist("Test Artist", self.network) # Act / Assert - self.assertFalse(artist1 == artist2) + self.assertNotEqual(artist1, artist2) def test_artist_ne_none_is_true(self): # Arrange @@ -271,7 +271,7 @@ class TestPyLastArtist(PyLastTestCase): artist2 = pylast.Artist("Test Artist", self.network) # Act / Assert - self.assertTrue(artist1 != artist2) + self.assertNotEqual(artist1, artist2) def test_artist_get_correction(self): # Arrange diff --git a/tests/test_pylast_country.py b/tests/test_pylast_country.py index 7d9554e..4f6b25f 100755 --- a/tests/test_pylast_country.py +++ b/tests/test_pylast_country.py @@ -32,8 +32,8 @@ class TestPyLastCountry(PyLastTestCase): self.assertIn("Italy", rep) self.assertIn("pylast.Country", rep) self.assertEqual(text, "Italy") - self.assertTrue(country1 == country1) - self.assertTrue(country1 != country2) + self.assertEqual(country1, country1) + self.assertNotEqual(country1, country2) self.assertEqual(url, "https://www.last.fm/place/italy") diff --git a/tests/test_pylast_tag.py b/tests/test_pylast_tag.py index 8d5440e..e56aac5 100755 --- a/tests/test_pylast_tag.py +++ b/tests/test_pylast_tag.py @@ -54,8 +54,8 @@ class TestPyLastTag(PyLastTestCase): self.assertIn("pylast.Tag", tag_repr) self.assertIn("blues", tag_repr) self.assertEqual("blues", name) - self.assertTrue(tag1 == tag1) - self.assertTrue(tag1 != tag2) + self.assertEqual(tag1, tag1) + self.assertNotEqual(tag1, tag2) self.assertEqual(url, "https://www.last.fm/tag/blues") diff --git a/tests/test_pylast_user.py b/tests/test_pylast_user.py index 64494b0..ad12feb 100755 --- a/tests/test_pylast_user.py +++ b/tests/test_pylast_user.py @@ -41,16 +41,8 @@ class TestPyLastUser(PyLastTestCase): # Act / Assert self.assertEqual(user_1a, user_1b) - self.assertTrue(user_1a == user_1b) - self.assertFalse(user_1a != user_1b) - self.assertNotEqual(user_1a, user_2) - self.assertTrue(user_1a != user_2) - self.assertFalse(user_1a == user_2) - self.assertNotEqual(user_1a, not_a_user) - self.assertTrue(user_1a != not_a_user) - self.assertFalse(user_1a == not_a_user) def test_get_name(self): # Arrange @@ -431,7 +423,7 @@ class TestPyLastUser(PyLastTestCase): track2 = pylast.Track("Test Artist", "test title", self.network) # Act / Assert - self.assertFalse(track1 == track2) + self.assertNotEqual(track1, track2) def test_track_ne_none_is_true(self): # Arrange @@ -439,7 +431,7 @@ class TestPyLastUser(PyLastTestCase): track2 = pylast.Track("Test Artist", "test title", self.network) # Act / Assert - self.assertTrue(track1 != track2) + self.assertNotEqual(track1, track2) def test_track_get_correction(self): # Arrange @@ -459,7 +451,7 @@ class TestPyLastUser(PyLastTestCase): mbid = track.get_mbid() # Assert - self.assertEqual(mbid, None) + self.assertIsNone(mbid) def test_get_playcount(self): # Arrange