Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_macpath.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | b36cb4602e21 |
| children |
| 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 |
|
59408
ebdc2aa730c0
Create test_genericpath.CommonTest and reuse it to test other path modules.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
59172
diff
changeset
|
2 from test import test_support, test_genericpath |
|
26627
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): |
|
58965
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
9 self.assertEqual(macpath.abspath("xx:yy"), "xx:yy") |
|
58964
7ab63884d68b
Merged revisions 78247 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
41057
diff
changeset
|
10 |
|
26627
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 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
|
22 split = macpath.split |
|
58965
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
23 self.assertEqual(split("foo:bar"), |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
24 ('foo:', 'bar')) |
|
58965
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
25 self.assertEqual(split("conky:mountpoint:foo:bar"), |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
26 ('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
|
27 |
|
58965
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
28 self.assertEqual(split(":"), ('', '')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
29 self.assertEqual(split(":conky:mountpoint:"), |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
30 (':conky:mountpoint', '')) |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
31 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
32 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
|
33 splitext = macpath.splitext |
|
58965
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
34 self.assertEqual(splitext(":foo.ext"), (':foo', '.ext')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
35 self.assertEqual(splitext("foo:foo.ext"), ('foo:foo', '.ext')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
36 self.assertEqual(splitext(".ext"), ('.ext', '')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
37 self.assertEqual(splitext("foo.ext:foo"), ('foo.ext:foo', '')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
38 self.assertEqual(splitext(":foo.ext:"), (':foo.ext:', '')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
39 self.assertEqual(splitext(""), ('', '')) |
|
3a7132f65623
Remove e assertIs definitions and use correct assert* methods.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58963
diff
changeset
|
40 self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext')) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
41 |
|
59172
aba9f6541ad6
Add a test for normpath to test_macpath.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58971
diff
changeset
|
42 def test_normpath(self): |
|
aba9f6541ad6
Add a test for normpath to test_macpath.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58971
diff
changeset
|
43 # Issue 5827: Make sure normpath preserves unicode |
|
aba9f6541ad6
Add a test for normpath to test_macpath.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58971
diff
changeset
|
44 for path in (u'', u'.', u'/', u'\\', u':', u'///foo/.//bar//'): |
|
aba9f6541ad6
Add a test for normpath to test_macpath.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58971
diff
changeset
|
45 self.assertIsInstance(macpath.normpath(path), unicode, |
|
aba9f6541ad6
Add a test for normpath to test_macpath.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58971
diff
changeset
|
46 'normpath() returned str instead of unicode') |
|
aba9f6541ad6
Add a test for normpath to test_macpath.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58971
diff
changeset
|
47 |
|
59408
ebdc2aa730c0
Create test_genericpath.CommonTest and reuse it to test other path modules.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
59172
diff
changeset
|
48 class MacCommonTest(test_genericpath.CommonTest): |
|
59409
a07f70fc82a1
Minor tweaking of previous r78734, and add a NEWS entry.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
59408
diff
changeset
|
49 pathmodule = macpath |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
50 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
51 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
52 def test_main(): |
|
59408
ebdc2aa730c0
Create test_genericpath.CommonTest and reuse it to test other path modules.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
59172
diff
changeset
|
53 test_support.run_unittest(MacPathTestCase, MacCommonTest) |
|
26627
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
54 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
55 |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
56 if __name__ == "__main__": |
|
7babdaea7d19
Patch #536661: Improve performance of splitext. Add test_macpath.
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
57 test_main() |
