本文整理汇总了Python中playlist.Playlist.to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.to_string方法的具体用法?Python Playlist.to_string怎么用?Python Playlist.to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.to_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPlaylist
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import to_string [as 别名]
class TestPlaylist(unittest.TestCase):
def setUp(self):
self.playlist = Playlist('my_playlist')
self.untitled = Playlist()
self.song_1 = Song(
'Hells Bells',
'AC/DC',
'rough and though',
4,
400,
256)
self.song_2 = Song(
'For Whom the Bell Tolls',
'Metallica',
'For Whom the Bell Tolls',
5,
500,
320)
def test_playlist_init(self):
self.assertEqual(self.playlist.name, 'my_playlist')
self.assertEqual(self.untitled.name, 'Untitled')
def test_add_song(self):
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
def test_remove_song(self):
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.playlist.remove_song('Hells Bells')
self.assertEqual(len(self.playlist.songs), 1)
def test_total_length(self):
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.assertEqual(self.playlist.total_length(), 2100)
def test_remove_disrated(self):
self.song_1.set_rating(3)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.playlist.remove_disrated(4)
self.assertEqual(len(self.playlist.songs), 1)
def test_remove_bad_quality(self):
self.song_1.bitrate = 92
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.playlist.remove_bad_quality()
self.assertEqual(len(self.playlist.songs), 1)
def test_show_artists(self):
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
# print(self.playlist.show_artists())
def test_to_string(self):
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
print(self.playlist.to_string())
def test_save(self):
# pass
self.playlist.add_song(self.song_2)
self.playlist.add_song(self.song_1)
self.playlist.add_song(self.song_2)
self.playlist.save('playlist.json')
def test_load(self):
# pass
plst = Playlist.load('playlist.json')
print(plst.to_string)