Merge pull request #245 from pylast/update-unittest-asserts

Use more helpful assert methods
This commit is contained in:
Hugo 2018-01-27 13:16:22 +02:00 committed by GitHub
commit e0f52ac27d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 32 deletions

View file

@ -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()}

View file

@ -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

View file

@ -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

View file

@ -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")

View file

@ -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")

View file

@ -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