Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(29558)

Side by Side Diff: Lib/test/test_macpath.py

Issue 4755: Common path prefix
Patch Set: Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 import macpath 1 import macpath
2 from test import support 2 from test import support
3 import unittest 3 import unittest
4 4
5 5
6 class MacPathTestCase(unittest.TestCase): 6 class MacPathTestCase(unittest.TestCase):
7 7
8 def test_abspath(self): 8 def test_abspath(self):
9 self.assertEqual(macpath.abspath("xx:yy"), "xx:yy") 9 self.assertEqual(macpath.abspath("xx:yy"), "xx:yy")
10 10
(...skipping 24 matching lines...) Expand all
35 == ":home:swen:") 35 == ":home:swen:")
36 self.assert_(commonprefix([":home:swen:spam", ":home:swen:spam"]) 36 self.assert_(commonprefix([":home:swen:spam", ":home:swen:spam"])
37 == ":home:swen:spam") 37 == ":home:swen:spam")
38 38
39 self.assert_(commonprefix([b"home:swenson:spam", b"home:swen:spam"]) 39 self.assert_(commonprefix([b"home:swenson:spam", b"home:swen:spam"])
40 == b"home:swen") 40 == b"home:swen")
41 self.assert_(commonprefix([b":home:swen:spam", b":home:swen:eggs"]) 41 self.assert_(commonprefix([b":home:swen:spam", b":home:swen:eggs"])
42 == b":home:swen:") 42 == b":home:swen:")
43 self.assert_(commonprefix([b":home:swen:spam", b":home:swen:spam"]) 43 self.assert_(commonprefix([b":home:swen:spam", b":home:swen:spam"])
44 == b":home:swen:spam") 44 == b":home:swen:spam")
45
46 def test_commonpathprefix(self):
47 commonpathprefix = macpath.commonpathprefix
48 self.assertEqual(
49 commonpathprefix([]),
50 ""
51 )
52 self.assertEqual(
53 commonpathprefix([":home:swenson:spam", ":home:swen:spam"]),
54 ":home"
55 )
56 self.assertEqual(
57 commonpathprefix([":home:swen:spam", ":home:swen:eggs"]),
58 ":home:swen"
59 )
60 self.assertEqual(
61 commonpathprefix([":home:swen:spam", ":home:swen:spam"]),
62 ":home:swen:spam"
63 )
64 self.assertEqual(
65 commonpathprefix([":home:swen:spam", "swen:spam"]),
66 ""
67 )
68 self.assertEqual(
69 commonpathprefix(["swen:eggs", "swen:spam"]),
70 "swen"
71 )
72 self.assertEqual(
73 commonpathprefix([":export:home:swen", ":etc:passwd"]),
74 ""
75 )
45 76
46 def test_split(self): 77 def test_split(self):
47 split = macpath.split 78 split = macpath.split
48 self.assertEquals(split("foo:bar"), 79 self.assertEquals(split("foo:bar"),
49 ('foo:', 'bar')) 80 ('foo:', 'bar'))
50 self.assertEquals(split("conky:mountpoint:foo:bar"), 81 self.assertEquals(split("conky:mountpoint:foo:bar"),
51 ('conky:mountpoint:foo', 'bar')) 82 ('conky:mountpoint:foo', 'bar'))
52 83
53 self.assertEquals(split(":"), ('', '')) 84 self.assertEquals(split(":"), ('', ''))
54 self.assertEquals(split(":conky:mountpoint:"), 85 self.assertEquals(split(":conky:mountpoint:"),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 self.assertEqual(normpath(b":"), b":") 169 self.assertEqual(normpath(b":"), b":")
139 self.assertEqual(normpath(b"a:"), b"a:") 170 self.assertEqual(normpath(b"a:"), b"a:")
140 self.assertEqual(normpath(b"a:b:"), b"a:b") 171 self.assertEqual(normpath(b"a:b:"), b"a:b")
141 172
142 def test_main(): 173 def test_main():
143 support.run_unittest(MacPathTestCase) 174 support.run_unittest(MacPathTestCase)
144 175
145 176
146 if __name__ == "__main__": 177 if __name__ == "__main__":
147 test_main() 178 test_main()
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+