Test comparing with None
This commit is contained in:
parent
f8b2d52333
commit
b24d883db9
@ -33,6 +33,9 @@ class Artist(ImmutableObject):
|
||||
name = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
@ -65,6 +68,9 @@ class Album(ImmutableObject):
|
||||
super(Album, self).__init__(*args, **kwargs)
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
|
||||
@ -31,6 +31,9 @@ class ArtistTest(unittest.TestCase):
|
||||
artist2 = Artist(uri=u'uri', name=u'name')
|
||||
self.assertEqual(artist1, artist2)
|
||||
|
||||
def test_eq_none(self):
|
||||
self.assertNotEqual(Artist(), None)
|
||||
|
||||
def test_ne_name(self):
|
||||
artist1 = Artist(name=u'name1')
|
||||
artist2 = Artist(name=u'name2')
|
||||
@ -99,6 +102,9 @@ class AlbumTest(unittest.TestCase):
|
||||
album2 = Album(name=u'name', uri=u'uri', artists=artists, num_tracks=2)
|
||||
self.assertEqual(album1, album2)
|
||||
|
||||
def test_eq_none(self):
|
||||
self.assertNotEqual(Album(), None)
|
||||
|
||||
def test_ne_name(self):
|
||||
album1 = Album(name=u'name1')
|
||||
album2 = Album(name=u'name2')
|
||||
@ -277,6 +283,9 @@ class TrackTest(unittest.TestCase):
|
||||
track_no=1, date=date, length=100, bitrate=100, id=2)
|
||||
self.assertEqual(track1, track2)
|
||||
|
||||
def test_eq_none(self):
|
||||
self.assertNotEqual(Track(), None)
|
||||
|
||||
def test_ne_uri(self):
|
||||
track1 = Track(uri=u'uri1')
|
||||
track2 = Track(uri=u'uri2')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user