当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.delete_song方法代码示例

本文整理汇总了Python中playlist.Playlist.delete_song方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.delete_song方法的具体用法?Python Playlist.delete_song怎么用?Python Playlist.delete_song使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playlist.Playlist的用法示例。


在下文中一共展示了Playlist.delete_song方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import delete_song [as 别名]
class TestPlaylist(unittest.TestCase):
    def setUp(self):
        self.test_playlist = Playlist("Rocking songs")

    def test_init_playlist(self):
        self.assertEqual(self.test_playlist.name, "Rocking songs")

    def test_add_song(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        self.test_playlist.add_song(test_song)
        self.assertIn(test_song, self.test_playlist.playlist)

    def test_remove_song(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        self.test_playlist.delete_song(test_song)
        self.assertNotIn(test_song, self.test_playlist.playlist)

    def test_total_length(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        test_song2 = Song("Fuck me", "Metallica", "Rock it", 4, 100, 256)
        self.test_playlist.add_song(test_song)
        self.test_playlist.add_song(test_song2)
        self.assertEqual(280, self.test_playlist.total_length())

    def test_remove_disrated(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        self.test_playlist.add_song(test_song)
        test_song.rate(5)
        self.test_playlist.remove_disrated(5)
        self.assertNotIn(test_song, self.test_playlist.playlist)

    def test_remove_bad_quality(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        self.test_playlist.add_song(test_song)
        self.assertIsNot(test_song, self.test_playlist.remove_bad_quality())

    def test_show_artists(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        test_song1 = Song("BlaBla", "Metallica", "Black in black", 4, 180, 64)
        test_song2 = Song("Take", "Rihanna", "Black in black", 4, 180, 64)
        test_song3 = Song("me", "AC DC", "Black in black", 4, 180, 64)
        test_song4 = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        self.test_playlist.add_song(test_song)
        self.test_playlist.add_song(test_song1)
        self.test_playlist.add_song(test_song2)
        self.test_playlist.add_song(test_song3)
        self.test_playlist.add_song(test_song4)
        self.assertListEqual(["AC DC", "Metallica", "Rihanna"], self.test_playlist.show_artists())

    def test_str(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        self.test_playlist.add_song(test_song)
        self.assertEqual("AC DC Take me - 3:00", self.test_playlist.__str__(test_song))
开发者ID:kkashev,项目名称:hackbulgaria,代码行数:55,代码来源:test_playlist_class.py


注:本文中的playlist.Playlist.delete_song方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。