curds: Add a less than operator for playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
e6cc3716eb
commit
0873f0458c
|
@ -22,6 +22,9 @@ class Playlist():
|
|||
def __len__(self):
|
||||
return len(self.list)
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.name < other.name
|
||||
|
||||
def __str__(self):
|
||||
l = len(self.list)
|
||||
return f"{self.name}\n{l} Track{'s' if l != 1 else ''}"
|
||||
|
|
|
@ -204,3 +204,10 @@ class TestPlaylist(unittest.TestCase):
|
|||
|
||||
for i in range(len(plist)):
|
||||
self.assertEqual(plist[i], tracks[i])
|
||||
|
||||
def test_playlist_less_than(self):
|
||||
a = playlist.Playlist("A")
|
||||
b = playlist.Playlist("B")
|
||||
self.assertTrue( a < b)
|
||||
self.assertFalse(b < a)
|
||||
self.assertFalse(a < a)
|
||||
|
|
Loading…
Reference in New Issue