Test the quotemarks=True and quotemarks=False options of quote_local_unicode_path.
authorDaira Hopwood <daira@jacaranda.org>
Thu, 5 Feb 2015 02:22:27 +0000 (02:22 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Thu, 5 Feb 2015 02:22:27 +0000 (02:22 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/test_encodingutil.py

index 4621a196e08e8915e33ca8685f20e49ca939b5d0..98156c6f19cd9c8204478ba48c7ad3cb36c7dbbf 100644 (file)
@@ -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):