Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_macpath.py @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 6768b2350c57 |
| children | eaf8a93cdbff |
| rev | line source |
|---|---|
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
1 import macpath |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
2 from test import test_support |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
3 import unittest |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
4 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
5 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
6 class MacPathTestCase(unittest.TestCase): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
7 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
8 def test_abspath(self): |
|
55002
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
9 self.assertTrue(macpath.abspath("xx:yy") == "xx:yy") |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
10 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
11 def test_isabs(self): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
12 isabs = macpath.isabs |
|
55002
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
13 self.assertTrue(isabs("xx:yy")) |
|
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
14 self.assertTrue(isabs("xx:yy:")) |
|
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
15 self.assertTrue(isabs("xx:")) |
|
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
16 self.assertFalse(isabs("foo")) |
|
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
17 self.assertFalse(isabs(":foo")) |
|
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
18 self.assertFalse(isabs(":foo:bar")) |
|
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
19 self.assertFalse(isabs(":foo:bar:")) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
20 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
21 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
22 def test_commonprefix(self): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
23 commonprefix = macpath.commonprefix |
|
55002
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
24 self.assertTrue(commonprefix(["home:swenson:spam", "home:swen:spam"]) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
25 == "home:swen") |
|
55002
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
26 self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:eggs"]) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
27 == ":home:swen:") |
|
55002
6768b2350c57
convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents:
41057
diff
changeset
|
28 self.assertTrue(commonprefix([":home:swen:spam", ":home:swen:spam"]) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
29 == ":home:swen:spam") |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
30 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
31 def test_split(self): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
32 split = macpath.split |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
33 self.assertEquals(split("foo:bar"), |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
34 ('foo:', 'bar')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
35 self.assertEquals(split("conky:mountpoint:foo:bar"), |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
36 ('conky:mountpoint:foo', 'bar')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
37 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
38 self.assertEquals(split(":"), ('', '')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
39 self.assertEquals(split(":conky:mountpoint:"), |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
40 (':conky:mountpoint', '')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
41 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
42 def test_splitdrive(self): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
43 splitdrive = macpath.splitdrive |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
44 self.assertEquals(splitdrive("foo:bar"), ('', 'foo:bar')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
45 self.assertEquals(splitdrive(":foo:bar"), ('', ':foo:bar')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
46 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
47 def test_splitext(self): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
48 splitext = macpath.splitext |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
49 self.assertEquals(splitext(":foo.ext"), (':foo', '.ext')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
50 self.assertEquals(splitext("foo:foo.ext"), ('foo:foo', '.ext')) |
|
41057
98bbc93bd55b
Bug #1115886: os.path.splitext('.cshrc') gives now ('.cshrc', '').
Martin v. Löwis <martin@v.loewis.de>
parents:
26791
diff
changeset
|
51 self.assertEquals(splitext(".ext"), ('.ext', '')) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
52 self.assertEquals(splitext("foo.ext:foo"), ('foo.ext:foo', '')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
53 self.assertEquals(splitext(":foo.ext:"), (':foo.ext:', '')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
54 self.assertEquals(splitext(""), ('', '')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
55 self.assertEquals(splitext("foo.bar.ext"), ('foo.bar', '.ext')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
56 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
57 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
58 def test_main(): |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
59 test_support.run_unittest(MacPathTestCase) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
60 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
61 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
62 if __name__ == "__main__": |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
63 test_main() |
