From 9ac392802b6034aefd4c742ea9dd02813f4667d9 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Thu, 5 Feb 2015 02:22:27 +0000 Subject: [PATCH] Test the quotemarks=True and quotemarks=False options of quote_local_unicode_path. Signed-off-by: Daira Hopwood --- src/allmydata/test/test_encodingutil.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/allmydata/test/test_encodingutil.py b/src/allmydata/test/test_encodingutil.py index 4621a196..98156c6f 100644 --- a/src/allmydata/test/test_encodingutil.py +++ b/src/allmydata/test/test_encodingutil.py @@ -405,10 +405,21 @@ class QuotePaths(ReallyEqualMixin, unittest.TestCase): self.failUnlessReallyEqual(quote_path([u'foo', u'\nbar'], quotemarks=True), '"foo/\\x0abar"') self.failUnlessReallyEqual(quote_path([u'foo', u'\nbar'], quotemarks=False), '"foo/\\x0abar"') + def win32_other(win32, other): + return win32 if sys.platform == "win32" else other + self.failUnlessReallyEqual(quote_local_unicode_path(u"\\\\?\\C:\\foo"), - "'C:\\foo'" if sys.platform == "win32" else "'\\\\?\\C:\\foo'") + win32_other("'C:\\foo'", "'\\\\?\\C:\\foo'")) + self.failUnlessReallyEqual(quote_local_unicode_path(u"\\\\?\\C:\\foo", quotemarks=True), + win32_other("'C:\\foo'", "'\\\\?\\C:\\foo'")) + self.failUnlessReallyEqual(quote_local_unicode_path(u"\\\\?\\C:\\foo", quotemarks=False), + win32_other("C:\\foo", "\\\\?\\C:\\foo")) self.failUnlessReallyEqual(quote_local_unicode_path(u"\\\\?\\UNC\\foo\\bar"), - "'\\\\foo\\bar'" if sys.platform == "win32" else "'\\\\?\\UNC\\foo\\bar'") + win32_other("'\\\\foo\\bar'", "'\\\\?\\UNC\\foo\\bar'")) + self.failUnlessReallyEqual(quote_local_unicode_path(u"\\\\?\\UNC\\foo\\bar", quotemarks=True), + win32_other("'\\\\foo\\bar'", "'\\\\?\\UNC\\foo\\bar'")) + self.failUnlessReallyEqual(quote_local_unicode_path(u"\\\\?\\UNC\\foo\\bar", quotemarks=False), + win32_other("\\\\foo\\bar", "\\\\?\\UNC\\foo\\bar")) class UbuntuKarmicUTF8(EncodingUtil, unittest.TestCase): -- 2.45.2