PICARD-321: Support backslash in filenames on non-Windows OS

With this change backslashes can be used in filenames on systems other than Windows. Only if Windows compatibility is activated backslashes will be replaced as before.
This commit is contained in:
Philipp Wolfer
2019-12-12 17:52:00 +01:00
parent 086da47d72
commit 0855862c8c
6 changed files with 94 additions and 29 deletions

View File

@@ -63,6 +63,26 @@ class SanitizeDateTest(PicardTestCase):
self.assertNotEqual(util.sanitize_date("2006.03.02"), "2006-03-02")
class SanitizeFilenameTest(PicardTestCase):
def test_replace_slashes(self):
self.assertEqual(util.sanitize_filename("AC/DC"), "AC_DC")
def test_custom_replacement(self):
self.assertEqual(util.sanitize_filename("AC/DC", "|"), "AC|DC")
def test_win_compat(self):
self.assertEqual(util.sanitize_filename("AC\\/DC", win_compat=True), "AC__DC")
@unittest.skipUnless(IS_WIN, "windows test")
def test_replace_backslashes(self):
self.assertEqual(util.sanitize_filename("AC\\DC"), "AC_DC")
@unittest.skipIf(IS_WIN, "non-windows test")
def test_keep_backslashes(self):
self.assertEqual(util.sanitize_filename("AC\\DC"), "AC\\DC")
class TranslateArtistTest(PicardTestCase):
def test_latin(self):