self.failUnlessReallyEqual(quote_filepath(foo_bar_fp, quotemarks=False),
win32_other("C:\\foo\\bar", "/foo/bar"))
+ foo_longfp = FilePath(u'\\\\?\\C:\\foo')
+ self.failUnlessReallyEqual(quote_filepath(foo_longfp),
+ win32_other("'C:\\foo'", "'\\\\?\\C:\\foo'"))
+ self.failUnlessReallyEqual(quote_filepath(foo_longfp, quotemarks=True),
+ win32_other("'C:\\foo'", "'\\\\?\\C:\\foo'"))
+ self.failUnlessReallyEqual(quote_filepath(foo_longfp, quotemarks=False),
+ win32_other("C:\\foo", "\\\\?\\C:\\foo"))
+
class FilePaths(ReallyEqualMixin, unittest.TestCase):
def test_to_filepath(self):
return fp
def to_filepath(path):
- precondition(isinstance(path, basestring), path=path)
+ precondition(isinstance(path, unicode if use_unicode_filepath else basestring),
+ path=path)
if isinstance(path, unicode) and not use_unicode_filepath:
path = path.encode(filesystem_encoding)
+ if sys.platform == "win32":
+ _assert(isinstance(path, unicode), path=path)
+ if path.startswith(u"\\\\?\\") and len(path) > 4:
+ # FilePath normally strips trailing path separators, but not in this case.
+ path = path.rstrip(u"\\")
+
return FilePath(path)
def _decode(s):