Exemplo n.º 1
0
 def test_replace_unix_path_separator_from_config(self):
     self.i.title = 'one \\ two / three.mp3'
     self.lib.replacements = [(re.compile(r'[\\/]'), 'x')]
     with _common.platform_windows():
         p = self.i.destination()
     self.assertTrue('one x two x three.mp3' in p)
     self.lib.replacements = None
Exemplo n.º 2
0
 def _windows_bytestring_path(self, path):
     old_gfse = sys.getfilesystemencoding
     sys.getfilesystemencoding = lambda: 'mbcs'
     try:
         with _common.platform_windows():
             return util.bytestring_path(path)
     finally:
         sys.getfilesystemencoding = old_gfse
Exemplo n.º 3
0
 def test_syspath_windows_format_unc_path(self):
     # The \\?\ prefix on Windows behaves differently with UNC
     # (network share) paths.
     path = '\\\\server\\share\\file.mp3'
     with _common.platform_windows():
         outpath = util.syspath(path)
     self.assertTrue(isinstance(outpath, unicode))
     self.assertEqual(outpath, u'\\\\?\\UNC\\server\\share\\file.mp3')
Exemplo n.º 4
0
 def test_distination_windows_removes_both_separators(self):
     self.i.title = 'one \\ two / three.mp3'
     with _common.platform_windows():
         p = self.i.destination()
     self.assertFalse('one \\ two' in p)
     self.assertFalse('one / two' in p)
     self.assertFalse('two \\ three' in p)
     self.assertFalse('two / three' in p)
Exemplo n.º 5
0
 def _windows_bytestring_path(self, path):
     old_gfse = sys.getfilesystemencoding
     sys.getfilesystemencoding = lambda: 'mbcs'
     try:
         with _common.platform_windows():
             return util.bytestring_path(path)
     finally:
         sys.getfilesystemencoding = old_gfse
Exemplo n.º 6
0
 def test_syspath_windows_format_unc_path(self):
     # The \\?\ prefix on Windows behaves differently with UNC
     # (network share) paths.
     path = '\\\\server\\share\\file.mp3'
     with _common.platform_windows():
         outpath = util.syspath(path)
     self.assertTrue(isinstance(outpath, unicode))
     self.assertEqual(outpath, u'\\\\?\\UNC\\server\\share\\file.mp3')
Exemplo n.º 7
0
 def test_distination_windows_removes_both_separators(self):
     self.i.title = 'one \\ two / three.mp3'
     with _common.platform_windows():
         p = self.i.destination()
     self.assertFalse('one \\ two' in p)
     self.assertFalse('one / two' in p)
     self.assertFalse('two \\ three' in p)
     self.assertFalse('two / three' in p)
Exemplo n.º 8
0
 def test_sanitize_windows_replaces_illegal_chars(self):
     with _common.platform_windows():
         p = util.sanitize_path(u':*?"<>|')
     self.assertFalse(':' in p)
     self.assertFalse('*' in p)
     self.assertFalse('?' in p)
     self.assertFalse('"' in p)
     self.assertFalse('<' in p)
     self.assertFalse('>' in p)
     self.assertFalse('|' in p)
Exemplo n.º 9
0
 def test_sanitize_windows_replaces_illegal_chars(self):
     with _common.platform_windows():
         p = util.sanitize_path(u':*?"<>|')
     self.assertFalse(':' in p)
     self.assertFalse('*' in p)
     self.assertFalse('?' in p)
     self.assertFalse('"' in p)
     self.assertFalse('<' in p)
     self.assertFalse('>' in p)
     self.assertFalse('|' in p)
Exemplo n.º 10
0
 def test_syspath_windows_format(self):
     with _common.platform_windows():
         path = os.path.join('a', 'b', 'c')
         outpath = util.syspath(path)
     self.assertTrue(isinstance(outpath, unicode))
     self.assertTrue(outpath.startswith(u'\\\\?\\'))
Exemplo n.º 11
0
 def test_sanitize_windows_replaces_trailing_space(self):
     with _common.platform_windows():
         p = util.sanitize_path(u'one/two /three')
     self.assertFalse(' ' in p)
Exemplo n.º 12
0
 def test_syspath_windows_format(self):
     with _common.platform_windows():
         path = os.path.join('a', 'b', 'c')
         outpath = util.syspath(path)
     self.assertTrue(isinstance(outpath, unicode))
     self.assertTrue(outpath.startswith(u'\\\\?\\'))
Exemplo n.º 13
0
 def test_sanitize_windows_replaces_trailing_space(self):
     with _common.platform_windows():
         p = util.sanitize_path(u'one/two /three')
     self.assertFalse(' ' in p)