From ff03ecaa2774b5d8010749c88f2894181e0121c2 Mon Sep 17 00:00:00 2001 From: J0J0 T Date: Sun, 28 Aug 2022 20:05:16 +0200 Subject: [PATCH] convert: playlist: Add another Windows test Add test_playlist_write_and_read_unicode_windows: Writes 2 media file paths containing unicode characters, reads them in using M3UFile class again and tests if the contents is correct. --- test/test_m3ufile.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test_m3ufile.py b/test/test_m3ufile.py index c5b7f49ec..a59b8fb76 100644 --- a/test/test_m3ufile.py +++ b/test/test_m3ufile.py @@ -62,6 +62,32 @@ class M3UFileTest(unittest.TestCase): self.assertTrue(path.exists(the_playlist_file)) rmtree(tempdir) + @unittest.skipUnless(sys.platform == 'win32', 'win32') + def test_playlist_write_and_read_unicode_windows(self): + """Test saving unicode paths to a playlist file on Windows.""" + tempdir = bytestring_path(mkdtemp()) + the_playlist_file = path.join(tempdir, + b'playlist_write_and_read_windows.m3u8') + m3ufile = M3UFile(the_playlist_file) + m3ufile.set_contents([ + r"x:\This\is\å\path\to_a_file.mp3", + r"x:\This\is\another\path\tö_a_file.mp3" + ]) + m3ufile.write() + self.assertTrue(path.exists(the_playlist_file)) + m3ufile_read = M3UFile(the_playlist_file) + m3ufile_read.load() + self.assertEquals( + m3ufile.media_list[0], + path.join('x:\\', 'This', 'is', 'å', 'path', 'to_a_file.mp3') + ) + self.assertEquals( + m3ufile.media_list[1], + r"x:\This\is\another\path\tö_a_file.mp3", + path.join('x:\\', 'This', 'is', 'another', 'path', 'tö_a_file.mp3') + ) + rmtree(tempdir) + def test_playlist_load_ascii(self): """Test loading ascii paths from a playlist file.""" the_playlist_file = path.join(RSRC, b'playlist.m3u')