本文整理汇总了Python中playlist.Playlist.total_lenght方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.total_lenght方法的具体用法?Python Playlist.total_lenght怎么用?Python Playlist.total_lenght使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.total_lenght方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPlaylist
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import total_lenght [as 别名]
class TestPlaylist(unittest.TestCase):
def setUp(self):
self.song1 = Song("Title1", "Artist","Album", 5.0, 4, 320)
self.song2 = Song("Title2", "Artist","Album", 2.0, 2, 320)
self.song3 = Song("Title3", "Artist2","Album", 5.0, 4, 128)
self.my_playlist = Playlist("Playlist")
self.my_playlist.songs.append(self.song1)
self.my_playlist.songs.append(self.song2)
self.my_playlist.songs.append(self.song3)
def test_init(self):
self.assertEqual(self.my_playlist.songs, [self.song1, self.song2, self.song3])
self.assertEqual(self.my_playlist.name, "Playlist")
def test_add_song(self):
self.song4 = Song("Title", "Artist","Album", 5.0, 4.22, 320)
self.my_playlist.add_song(self.song4)
self.assertEqual(self.my_playlist.songs, [self.song1, self.song2, self.song3, self.song4])
def test_remove_song(self):
self.my_playlist.remove_song("Title2")
self.assertEqual(self.my_playlist.songs, [self.song1, self.song3])
def test_total_lenght(self):
self.assertEqual(self.my_playlist.total_lenght(), 10)
def test_remove_disrated(self):
self.my_playlist.remove_disrated(3)
self.assertEqual(self.my_playlist.songs, [self.song1, self.song3])
def test_remove_bad_quality(self):
self.my_playlist.remove_bad_quality(320)
self.assertEqual(self.my_playlist.songs, [self.song1, self.song2])
def test_show_artists(self):
self.assertEqual(self.my_playlist.show_artits(), ["Artist", "Artist2"])
def test_str(self):
print(self.my_playlist.str())