annotate Lib/test/test_genericpath.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 3a7132f65623
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39689
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
1 import unittest
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
2 from test import test_support
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
3 import os
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
4 import genericpath
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
5
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
6 class AllCommonTest(unittest.TestCase):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
7
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
8 def assertIs(self, a, b):
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 39689
diff changeset
9 self.assertTrue(a is b)
39689
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
10
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
11 def test_commonprefix(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
12 self.assertEqual(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
13 genericpath.commonprefix([]),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
14 ""
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
15 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
16 self.assertEqual(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
17 genericpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"]),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
18 "/home/swen"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
19 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
20 self.assertEqual(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
21 genericpath.commonprefix(["/home/swen/spam", "/home/swen/eggs"]),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
22 "/home/swen/"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
23 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
24 self.assertEqual(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
25 genericpath.commonprefix(["/home/swen/spam", "/home/swen/spam"]),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
26 "/home/swen/spam"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
27 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
28
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
29 def test_getsize(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
30 f = open(test_support.TESTFN, "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
31 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
32 f.write("foo")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
33 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
34 self.assertEqual(genericpath.getsize(test_support.TESTFN), 3)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
35 finally:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
36 if not f.closed:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
37 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
38 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
39
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
40 def test_time(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
41 f = open(test_support.TESTFN, "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
42 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
43 f.write("foo")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
44 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
45 f = open(test_support.TESTFN, "ab")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
46 f.write("bar")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
47 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
48 f = open(test_support.TESTFN, "rb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
49 d = f.read()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
50 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
51 self.assertEqual(d, "foobar")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
52
55002
6768b2350c57 convert usage of fail* to assert*
Benjamin Peterson <benjamin@python.org>
parents: 39689
diff changeset
53 self.assertTrue(
39689
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
54 genericpath.getctime(test_support.TESTFN) <=
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
55 genericpath.getmtime(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
56 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
57 finally:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
58 if not f.closed:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
59 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
60 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
61
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
62 def test_exists(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
63 self.assertIs(genericpath.exists(test_support.TESTFN), False)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
64 f = open(test_support.TESTFN, "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
65 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
66 f.write("foo")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
67 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
68 self.assertIs(genericpath.exists(test_support.TESTFN), True)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
69 finally:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
70 if not f.close():
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
71 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
72 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
73 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
74 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
75 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
76
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
77 self.assertRaises(TypeError, genericpath.exists)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
78
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
79 def test_isdir(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
80 self.assertIs(genericpath.isdir(test_support.TESTFN), False)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
81 f = open(test_support.TESTFN, "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
82 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
83 f.write("foo")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
84 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
85 self.assertIs(genericpath.isdir(test_support.TESTFN), False)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
86 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
87 os.mkdir(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
88 self.assertIs(genericpath.isdir(test_support.TESTFN), True)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
89 os.rmdir(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
90 finally:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
91 if not f.close():
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
92 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
93 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
94 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
95 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
96 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
97 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
98 os.rmdir(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
99 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
100 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
101
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
102 self.assertRaises(TypeError, genericpath.isdir)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
103
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
104 def test_isfile(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
105 self.assertIs(genericpath.isfile(test_support.TESTFN), False)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
106 f = open(test_support.TESTFN, "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
107 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
108 f.write("foo")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
109 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
110 self.assertIs(genericpath.isfile(test_support.TESTFN), True)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
111 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
112 os.mkdir(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
113 self.assertIs(genericpath.isfile(test_support.TESTFN), False)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
114 os.rmdir(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
115 finally:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
116 if not f.close():
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
117 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
118 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
119 os.remove(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
120 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
121 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
122 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
123 os.rmdir(test_support.TESTFN)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
124 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
125 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
126
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
127 self.assertRaises(TypeError, genericpath.isdir)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
128
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
129 def test_samefile(self):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
130 f = open(test_support.TESTFN + "1", "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
131 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
132 f.write("foo")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
133 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
134 self.assertIs(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
135 genericpath.samefile(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
136 test_support.TESTFN + "1",
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
137 test_support.TESTFN + "1"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
138 ),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
139 True
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
140 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
141 # If we don't have links, assume that os.stat doesn't return resonable
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
142 # inode information and thus, that samefile() doesn't work
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
143 if hasattr(os, "symlink"):
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
144 os.symlink(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
145 test_support.TESTFN + "1",
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
146 test_support.TESTFN + "2"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
147 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
148 self.assertIs(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
149 genericpath.samefile(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
150 test_support.TESTFN + "1",
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
151 test_support.TESTFN + "2"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
152 ),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
153 True
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
154 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
155 os.remove(test_support.TESTFN + "2")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
156 f = open(test_support.TESTFN + "2", "wb")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
157 f.write("bar")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
158 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
159 self.assertIs(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
160 genericpath.samefile(
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
161 test_support.TESTFN + "1",
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
162 test_support.TESTFN + "2"
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
163 ),
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
164 False
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
165 )
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
166 finally:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
167 if not f.close():
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
168 f.close()
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
169 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
170 os.remove(test_support.TESTFN + "1")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
171 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
172 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
173 try:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
174 os.remove(test_support.TESTFN + "2")
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
175 except os.error:
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
176 pass
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
177
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
178 self.assertRaises(TypeError, genericpath.samefile)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
179
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
180 def test_main():
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
181 test_support.run_unittest(AllCommonTest)
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
182
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
183 if __name__=="__main__":
d0ed7dbaad56 - Move functions common to all path modules into genericpath.py and have the
Jack Diederich <jackdied@gmail.com>
parents:
diff changeset
184 test_main()