class PlaylistTests(unittest.TestCase): def setUp(self): self.song1 = Song( title="Bullet with Butterfly Wings", artist="Smashing Pumpkins", time='00:04:17' ) self.song2 = Song( title="Song 2", artist="Blur", time="00:02:01" ) self.song3 = Song( title="Creep", artist="Radiohead", time="00:03:58" ) self.playlist = Playlist( [self.song1, self.song2, self.song3] ) def test_playlist_length(self): self.assertEqual(len(self.playlist), 3) def test_play_time(self): self.assertEqual(self.playlist.play_time, 616) def test_play_next_song(self): self.playlist.play_next_song() self.assertLess(self.playlist.play_time, 616) def test_play_next_song_when_empty(self): playlist2 = Playlist() with self.assertRaises(IndexError): playlist2.play_next_song()
def test_play_next_song_when_empty(self): playlist2 = Playlist() with self.assertRaises(IndexError): playlist2.play_next_song()