mirror of
https://github.com/beetbox/beets.git
synced 2026-02-21 23:03:26 +01:00
convert: playlist: Add tests checking extm3u and
fix extm3u check in load method.
This commit is contained in:
parent
68240f6e03
commit
39e4b90b5c
3 changed files with 15 additions and 1 deletions
|
|
@ -162,7 +162,7 @@ class M3UFile():
|
|||
"""
|
||||
with open(self.path, "r") as playlist_file:
|
||||
raw_contents = playlist_file.readlines()
|
||||
self.extm3u = True if raw_contents[0] == "#EXTM3U" else False
|
||||
self.extm3u = True if raw_contents[0] == "#EXTM3U\n" else False
|
||||
for line in raw_contents[1:]:
|
||||
if line.startswith("#"):
|
||||
# Some EXTM3U comment, do something. FIXME
|
||||
|
|
|
|||
2
test/rsrc/playlist_non_ext.m3u
Normal file
2
test/rsrc/playlist_non_ext.m3u
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/This/is/a/path/to_a_file.mp3
|
||||
/This/is/another/path/to_a_file.mp3
|
||||
|
|
@ -72,6 +72,18 @@ class M3UFileTest(unittest.TestCase):
|
|||
self.assertEqual(m3ufile.media_list[0],
|
||||
'/This/is/å/path/to_a_file.mp3\n')
|
||||
|
||||
def test_playlist_load_extm3u(self):
|
||||
the_playlist_file = path.join(RSRC, b'playlist.m3u')
|
||||
m3ufile = M3UFile(the_playlist_file)
|
||||
m3ufile.load()
|
||||
self.assertTrue(m3ufile.extm3u)
|
||||
|
||||
def test_playlist_load_non_extm3u(self):
|
||||
the_playlist_file = path.join(RSRC, b'playlist_non_ext.m3u')
|
||||
m3ufile = M3UFile(the_playlist_file)
|
||||
m3ufile.load()
|
||||
self.assertFalse(m3ufile.extm3u)
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue