]> granicus.if.org Git - python/commitdiff
Better tests for posixpath.commonprefix
authorRaymond Hettinger <python@rcn.com>
Fri, 11 May 2007 17:59:59 +0000 (17:59 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 11 May 2007 17:59:59 +0000 (17:59 +0000)
Lib/test/test_posixpath.py

index 0abf4646c450d2c38633ab2a86a11e9dc75d9bbc..88aa68c5b3caa7c07fbcfb4e02984f9f5b777ab5 100644 (file)
@@ -130,6 +130,16 @@ class PosixPathTest(unittest.TestCase):
             "/home/swen/spam"
         )
 
+        testlist = ['', 'abc', 'Xbcd', 'Xb', 'XY', 'abcd', 'aXc', 'abd', 'ab', 'aX', 'abcX']
+        for s1 in testlist:
+            for s2 in testlist:
+                p = posixpath.commonprefix([s1, s2])
+                self.assert_(s1.startswith(p))
+                self.assert_(s2.startswith(p))
+                if s1 != s2:
+                    n = len(p)
+                    self.assertNotEqual(s1[n:n+1], s2[n:n+1])
+
     def test_getsize(self):
         f = open(test_support.TESTFN, "wb")
         try: