blob: 1268fa362232df7604dfd9a83ea7a18b3f2f010b [file] [log] [blame]
Fred Drake38c2ef02001-07-17 20:52:51 +00001# As a test suite for the os module, this is woefully inadequate, but this
2# does add tests for a few functions which have been determined to be more
Walter Dörwaldf0dfc7a2003-10-20 14:01:56 +00003# portable than they had been thought to be.
Fred Drake38c2ef02001-07-17 20:52:51 +00004
5import os
Benjamin Peterson1de05e92009-01-31 01:42:55 +00006import errno
Fred Drake38c2ef02001-07-17 20:52:51 +00007import unittest
Jeremy Hyltona7fc21b2001-08-20 20:10:01 +00008import warnings
Martin v. Löwis8e0d4942006-05-04 10:08:42 +00009import sys
Brian Curtine5aa8862010-04-02 23:26:06 +000010import signal
11import subprocess
12import time
Barry Warsaw1e13eb02012-02-20 20:42:21 -050013
Walter Dörwald21d3a322003-05-01 17:45:56 +000014from test import test_support
Hirokazu Yamamoto1f504f12010-10-08 09:41:13 +000015import mmap
16import uuid
Fred Drake38c2ef02001-07-17 20:52:51 +000017
Barry Warsaw60f01882001-08-22 19:24:42 +000018warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
19warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
20
Martin v. Löwisee1e06d2006-07-02 18:44:00 +000021# Tests creating TESTFN
22class FileTests(unittest.TestCase):
23 def setUp(self):
24 if os.path.exists(test_support.TESTFN):
25 os.unlink(test_support.TESTFN)
26 tearDown = setUp
27
28 def test_access(self):
29 f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
30 os.close(f)
Benjamin Peterson5c8da862009-06-30 22:57:08 +000031 self.assertTrue(os.access(test_support.TESTFN, os.W_OK))
Tim Peters16a39322006-07-03 08:23:19 +000032
Georg Brandl309501a2008-01-19 20:22:13 +000033 def test_closerange(self):
Antoine Pitroubebb18b2008-08-17 14:43:41 +000034 first = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
35 # We must allocate two consecutive file descriptors, otherwise
36 # it will mess up other file descriptors (perhaps even the three
37 # standard ones).
38 second = os.dup(first)
39 try:
40 retries = 0
41 while second != first + 1:
42 os.close(first)
43 retries += 1
44 if retries > 10:
45 # XXX test skipped
Benjamin Peterson757b3c92009-05-16 18:44:34 +000046 self.skipTest("couldn't allocate two consecutive fds")
Antoine Pitroubebb18b2008-08-17 14:43:41 +000047 first, second = second, os.dup(second)
48 finally:
49 os.close(second)
Georg Brandl309501a2008-01-19 20:22:13 +000050 # close a fd that is open, and one that isn't
Antoine Pitroubebb18b2008-08-17 14:43:41 +000051 os.closerange(first, first + 2)
52 self.assertRaises(OSError, os.write, first, "a")
Georg Brandl309501a2008-01-19 20:22:13 +000053
Benjamin Peterson10947a62010-06-30 17:11:08 +000054 @test_support.cpython_only
Hirokazu Yamamoto74ce88f2008-09-08 23:03:47 +000055 def test_rename(self):
56 path = unicode(test_support.TESTFN)
57 old = sys.getrefcount(path)
58 self.assertRaises(TypeError, os.rename, path, 0)
59 new = sys.getrefcount(path)
60 self.assertEqual(old, new)
61
Martin v. Löwisee1e06d2006-07-02 18:44:00 +000062
Fred Drake38c2ef02001-07-17 20:52:51 +000063class TemporaryFileTests(unittest.TestCase):
64 def setUp(self):
65 self.files = []
Walter Dörwald21d3a322003-05-01 17:45:56 +000066 os.mkdir(test_support.TESTFN)
Fred Drake38c2ef02001-07-17 20:52:51 +000067
68 def tearDown(self):
69 for name in self.files:
70 os.unlink(name)
Walter Dörwald21d3a322003-05-01 17:45:56 +000071 os.rmdir(test_support.TESTFN)
Fred Drake38c2ef02001-07-17 20:52:51 +000072
73 def check_tempfile(self, name):
74 # make sure it doesn't already exist:
Benjamin Peterson5c8da862009-06-30 22:57:08 +000075 self.assertFalse(os.path.exists(name),
Fred Drake38c2ef02001-07-17 20:52:51 +000076 "file already exists for temporary file")
77 # make sure we can create the file
78 open(name, "w")
79 self.files.append(name)
80
81 def test_tempnam(self):
82 if not hasattr(os, "tempnam"):
83 return
Antoine Pitroub0614612011-01-02 20:04:52 +000084 with warnings.catch_warnings():
85 warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
86 r"test_os$")
87 warnings.filterwarnings("ignore", "tempnam", DeprecationWarning)
88 self.check_tempfile(os.tempnam())
Fred Drake38c2ef02001-07-17 20:52:51 +000089
Antoine Pitroub0614612011-01-02 20:04:52 +000090 name = os.tempnam(test_support.TESTFN)
91 self.check_tempfile(name)
Fred Drake38c2ef02001-07-17 20:52:51 +000092
Antoine Pitroub0614612011-01-02 20:04:52 +000093 name = os.tempnam(test_support.TESTFN, "pfx")
94 self.assertTrue(os.path.basename(name)[:3] == "pfx")
95 self.check_tempfile(name)
Fred Drake38c2ef02001-07-17 20:52:51 +000096
97 def test_tmpfile(self):
98 if not hasattr(os, "tmpfile"):
99 return
Martin v. Löwisd2bbe522008-03-06 06:55:22 +0000100 # As with test_tmpnam() below, the Windows implementation of tmpfile()
101 # attempts to create a file in the root directory of the current drive.
102 # On Vista and Server 2008, this test will always fail for normal users
103 # as writing to the root directory requires elevated privileges. With
104 # XP and below, the semantics of tmpfile() are the same, but the user
105 # running the test is more likely to have administrative privileges on
106 # their account already. If that's the case, then os.tmpfile() should
107 # work. In order to make this test as useful as possible, rather than
108 # trying to detect Windows versions or whether or not the user has the
109 # right permissions, just try and create a file in the root directory
110 # and see if it raises a 'Permission denied' OSError. If it does, then
111 # test that a subsequent call to os.tmpfile() raises the same error. If
112 # it doesn't, assume we're on XP or below and the user running the test
113 # has administrative privileges, and proceed with the test as normal.
Antoine Pitroub0614612011-01-02 20:04:52 +0000114 with warnings.catch_warnings():
115 warnings.filterwarnings("ignore", "tmpfile", DeprecationWarning)
Martin v. Löwisd2bbe522008-03-06 06:55:22 +0000116
Antoine Pitroub0614612011-01-02 20:04:52 +0000117 if sys.platform == 'win32':
118 name = '\\python_test_os_test_tmpfile.txt'
119 if os.path.exists(name):
120 os.remove(name)
121 try:
122 fp = open(name, 'w')
123 except IOError, first:
124 # open() failed, assert tmpfile() fails in the same way.
125 # Although open() raises an IOError and os.tmpfile() raises an
126 # OSError(), 'args' will be (13, 'Permission denied') in both
127 # cases.
128 try:
129 fp = os.tmpfile()
130 except OSError, second:
131 self.assertEqual(first.args, second.args)
132 else:
133 self.fail("expected os.tmpfile() to raise OSError")
134 return
135 else:
136 # open() worked, therefore, tmpfile() should work. Close our
137 # dummy file and proceed with the test as normal.
138 fp.close()
139 os.remove(name)
140
141 fp = os.tmpfile()
142 fp.write("foobar")
143 fp.seek(0,0)
144 s = fp.read()
145 fp.close()
146 self.assertTrue(s == "foobar")
Fred Drake38c2ef02001-07-17 20:52:51 +0000147
148 def test_tmpnam(self):
149 if not hasattr(os, "tmpnam"):
150 return
Antoine Pitroub0614612011-01-02 20:04:52 +0000151 with warnings.catch_warnings():
152 warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
153 r"test_os$")
154 warnings.filterwarnings("ignore", "tmpnam", DeprecationWarning)
155
156 name = os.tmpnam()
157 if sys.platform in ("win32",):
158 # The Windows tmpnam() seems useless. From the MS docs:
159 #
160 # The character string that tmpnam creates consists of
161 # the path prefix, defined by the entry P_tmpdir in the
162 # file STDIO.H, followed by a sequence consisting of the
163 # digit characters '0' through '9'; the numerical value
164 # of this string is in the range 1 - 65,535. Changing the
165 # definitions of L_tmpnam or P_tmpdir in STDIO.H does not
166 # change the operation of tmpnam.
167 #
168 # The really bizarre part is that, at least under MSVC6,
169 # P_tmpdir is "\\". That is, the path returned refers to
170 # the root of the current drive. That's a terrible place to
171 # put temp files, and, depending on privileges, the user
172 # may not even be able to open a file in the root directory.
173 self.assertFalse(os.path.exists(name),
174 "file already exists for temporary file")
175 else:
176 self.check_tempfile(name)
Tim Peters87cc0c32001-07-21 01:41:30 +0000177
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000178# Test attributes on return values from os.*stat* family.
179class StatAttributeTests(unittest.TestCase):
180 def setUp(self):
Walter Dörwald21d3a322003-05-01 17:45:56 +0000181 os.mkdir(test_support.TESTFN)
182 self.fname = os.path.join(test_support.TESTFN, "f1")
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000183 f = open(self.fname, 'wb')
184 f.write("ABC")
185 f.close()
Tim Peterse0c446b2001-10-18 21:57:37 +0000186
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000187 def tearDown(self):
188 os.unlink(self.fname)
Walter Dörwald21d3a322003-05-01 17:45:56 +0000189 os.rmdir(test_support.TESTFN)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000190
191 def test_stat_attributes(self):
192 if not hasattr(os, "stat"):
193 return
194
195 import stat
196 result = os.stat(self.fname)
197
198 # Make sure direct access works
Ezio Melotti2623a372010-11-21 13:34:58 +0000199 self.assertEqual(result[stat.ST_SIZE], 3)
200 self.assertEqual(result.st_size, 3)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000201
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000202 # Make sure all the attributes are there
203 members = dir(result)
204 for name in dir(stat):
205 if name[:3] == 'ST_':
206 attr = name.lower()
Martin v. Löwis4d394df2005-01-23 09:19:22 +0000207 if name.endswith("TIME"):
208 def trunc(x): return int(x)
209 else:
210 def trunc(x): return x
Ezio Melotti2623a372010-11-21 13:34:58 +0000211 self.assertEqual(trunc(getattr(result, attr)),
212 result[getattr(stat, name)])
Ezio Melottiaa980582010-01-23 23:04:36 +0000213 self.assertIn(attr, members)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000214
215 try:
216 result[200]
217 self.fail("No exception thrown")
218 except IndexError:
219 pass
220
221 # Make sure that assignment fails
222 try:
223 result.st_mode = 1
224 self.fail("No exception thrown")
Benjamin Petersonc262a692010-06-30 18:41:08 +0000225 except (AttributeError, TypeError):
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000226 pass
227
228 try:
229 result.st_rdev = 1
230 self.fail("No exception thrown")
Guido van Rossum1fff8782001-10-18 21:19:31 +0000231 except (AttributeError, TypeError):
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000232 pass
233
234 try:
235 result.parrot = 1
236 self.fail("No exception thrown")
237 except AttributeError:
238 pass
239
240 # Use the stat_result constructor with a too-short tuple.
241 try:
242 result2 = os.stat_result((10,))
243 self.fail("No exception thrown")
244 except TypeError:
245 pass
246
Ezio Melotti24b07bc2011-03-15 18:55:01 +0200247 # Use the constructor with a too-long tuple.
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000248 try:
249 result2 = os.stat_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14))
250 except TypeError:
251 pass
252
Tim Peterse0c446b2001-10-18 21:57:37 +0000253
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000254 def test_statvfs_attributes(self):
255 if not hasattr(os, "statvfs"):
256 return
257
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000258 try:
259 result = os.statvfs(self.fname)
260 except OSError, e:
261 # On AtheOS, glibc always returns ENOSYS
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000262 if e.errno == errno.ENOSYS:
263 return
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000264
265 # Make sure direct access works
Ezio Melotti2623a372010-11-21 13:34:58 +0000266 self.assertEqual(result.f_bfree, result[3])
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000267
Brett Cannon90f2cb42008-05-16 00:37:42 +0000268 # Make sure all the attributes are there.
269 members = ('bsize', 'frsize', 'blocks', 'bfree', 'bavail', 'files',
270 'ffree', 'favail', 'flag', 'namemax')
271 for value, member in enumerate(members):
Ezio Melotti2623a372010-11-21 13:34:58 +0000272 self.assertEqual(getattr(result, 'f_' + member), result[value])
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000273
274 # Make sure that assignment really fails
275 try:
276 result.f_bfree = 1
277 self.fail("No exception thrown")
278 except TypeError:
279 pass
280
281 try:
282 result.parrot = 1
283 self.fail("No exception thrown")
284 except AttributeError:
285 pass
286
287 # Use the constructor with a too-short tuple.
288 try:
289 result2 = os.statvfs_result((10,))
290 self.fail("No exception thrown")
291 except TypeError:
292 pass
293
Ezio Melotti24b07bc2011-03-15 18:55:01 +0200294 # Use the constructor with a too-long tuple.
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000295 try:
296 result2 = os.statvfs_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14))
297 except TypeError:
298 pass
Fred Drake38c2ef02001-07-17 20:52:51 +0000299
Martin v. Löwis18aaa562006-10-15 08:43:33 +0000300 def test_utime_dir(self):
301 delta = 1000000
302 st = os.stat(test_support.TESTFN)
Martin v. Löwisa97e06d2006-10-15 11:02:07 +0000303 # round to int, because some systems may support sub-second
304 # time stamps in stat, but not in utime.
305 os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
Martin v. Löwis18aaa562006-10-15 08:43:33 +0000306 st2 = os.stat(test_support.TESTFN)
Ezio Melotti2623a372010-11-21 13:34:58 +0000307 self.assertEqual(st2.st_mtime, int(st.st_mtime-delta))
Martin v. Löwis18aaa562006-10-15 08:43:33 +0000308
Martin v. Löwisf43893a2006-10-09 20:44:25 +0000309 # Restrict test to Win32, since there is no guarantee other
310 # systems support centiseconds
311 if sys.platform == 'win32':
Martin v. Löwis7dcb83c2007-08-30 19:04:09 +0000312 def get_file_system(path):
Hirokazu Yamamotoccfdcd02008-08-20 04:13:28 +0000313 root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'
Martin v. Löwis7dcb83c2007-08-30 19:04:09 +0000314 import ctypes
Hirokazu Yamamotocd3b74d2008-08-20 16:15:28 +0000315 kernel32 = ctypes.windll.kernel32
316 buf = ctypes.create_string_buffer("", 100)
317 if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)):
Martin v. Löwis7dcb83c2007-08-30 19:04:09 +0000318 return buf.value
319
320 if get_file_system(test_support.TESTFN) == "NTFS":
321 def test_1565150(self):
322 t1 = 1159195039.25
323 os.utime(self.fname, (t1, t1))
Ezio Melotti2623a372010-11-21 13:34:58 +0000324 self.assertEqual(os.stat(self.fname).st_mtime, t1)
Martin v. Löwisf43893a2006-10-09 20:44:25 +0000325
Amaury Forgeot d'Arcac514c82011-01-03 00:50:57 +0000326 def test_large_time(self):
327 t1 = 5000000000 # some day in 2128
328 os.utime(self.fname, (t1, t1))
329 self.assertEqual(os.stat(self.fname).st_mtime, t1)
330
Martin v. Löwis3bf573f2007-04-04 18:30:36 +0000331 def test_1686475(self):
332 # Verify that an open file can be stat'ed
333 try:
334 os.stat(r"c:\pagefile.sys")
335 except WindowsError, e:
Antoine Pitrou954ea642008-08-17 20:15:07 +0000336 if e.errno == 2: # file does not exist; cannot run test
Martin v. Löwis3bf573f2007-04-04 18:30:36 +0000337 return
338 self.fail("Could not stat pagefile.sys")
339
Walter Dörwald0a6d0ff2004-05-31 16:29:04 +0000340from test import mapping_tests
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000341
Walter Dörwald0a6d0ff2004-05-31 16:29:04 +0000342class EnvironTests(mapping_tests.BasicTestMappingProtocol):
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000343 """check that os.environ object conform to mapping protocol"""
Walter Dörwald118f9312004-06-02 18:42:25 +0000344 type2test = None
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000345 def _reference(self):
346 return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
347 def _empty_mapping(self):
348 os.environ.clear()
349 return os.environ
350 def setUp(self):
351 self.__save = dict(os.environ)
352 os.environ.clear()
353 def tearDown(self):
354 os.environ.clear()
355 os.environ.update(self.__save)
356
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000357 # Bug 1110478
Martin v. Löwis5510f652005-02-17 21:23:20 +0000358 def test_update2(self):
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000359 if os.path.exists("/bin/sh"):
360 os.environ.update(HELLO="World")
Brian Curtinfcbf5d02010-10-30 21:29:52 +0000361 with os.popen("/bin/sh -c 'echo $HELLO'") as popen:
362 value = popen.read().strip()
Ezio Melotti2623a372010-11-21 13:34:58 +0000363 self.assertEqual(value, "World")
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000364
Charles-François Natali27bc4d02011-11-27 13:05:14 +0100365 # On FreeBSD < 7 and OS X < 10.6, unsetenv() doesn't return a value (issue
366 # #13415).
367 @unittest.skipIf(sys.platform.startswith(('freebsd', 'darwin')),
368 "due to known OS bug: see issue #13415")
Victor Stinner53853c32011-11-22 22:20:13 +0100369 def test_unset_error(self):
370 if sys.platform == "win32":
371 # an environment variable is limited to 32,767 characters
372 key = 'x' * 50000
Victor Stinner091b6ef2011-11-22 22:30:19 +0100373 self.assertRaises(ValueError, os.environ.__delitem__, key)
Victor Stinner53853c32011-11-22 22:20:13 +0100374 else:
375 # "=" is not allowed in a variable name
376 key = 'key='
Victor Stinner091b6ef2011-11-22 22:30:19 +0100377 self.assertRaises(OSError, os.environ.__delitem__, key)
Victor Stinner53853c32011-11-22 22:20:13 +0100378
Tim Petersc4e09402003-04-25 07:11:48 +0000379class WalkTests(unittest.TestCase):
380 """Tests for os.walk()."""
381
382 def test_traversal(self):
383 import os
384 from os.path import join
385
386 # Build:
Neal Norwitz0d4c06e2007-04-25 06:30:05 +0000387 # TESTFN/
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000388 # TEST1/ a file kid and two directory kids
Tim Petersc4e09402003-04-25 07:11:48 +0000389 # tmp1
390 # SUB1/ a file kid and a directory kid
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000391 # tmp2
392 # SUB11/ no kids
393 # SUB2/ a file kid and a dirsymlink kid
394 # tmp3
395 # link/ a symlink to TESTFN.2
396 # TEST2/
397 # tmp4 a lone file
398 walk_path = join(test_support.TESTFN, "TEST1")
399 sub1_path = join(walk_path, "SUB1")
Tim Petersc4e09402003-04-25 07:11:48 +0000400 sub11_path = join(sub1_path, "SUB11")
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000401 sub2_path = join(walk_path, "SUB2")
402 tmp1_path = join(walk_path, "tmp1")
Tim Petersc4e09402003-04-25 07:11:48 +0000403 tmp2_path = join(sub1_path, "tmp2")
404 tmp3_path = join(sub2_path, "tmp3")
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000405 link_path = join(sub2_path, "link")
406 t2_path = join(test_support.TESTFN, "TEST2")
407 tmp4_path = join(test_support.TESTFN, "TEST2", "tmp4")
Tim Petersc4e09402003-04-25 07:11:48 +0000408
409 # Create stuff.
410 os.makedirs(sub11_path)
411 os.makedirs(sub2_path)
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000412 os.makedirs(t2_path)
413 for path in tmp1_path, tmp2_path, tmp3_path, tmp4_path:
Tim Petersc4e09402003-04-25 07:11:48 +0000414 f = file(path, "w")
415 f.write("I'm " + path + " and proud of it. Blame test_os.\n")
416 f.close()
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000417 if hasattr(os, "symlink"):
418 os.symlink(os.path.abspath(t2_path), link_path)
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000419 sub2_tree = (sub2_path, ["link"], ["tmp3"])
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000420 else:
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000421 sub2_tree = (sub2_path, [], ["tmp3"])
Tim Petersc4e09402003-04-25 07:11:48 +0000422
423 # Walk top-down.
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000424 all = list(os.walk(walk_path))
Tim Petersc4e09402003-04-25 07:11:48 +0000425 self.assertEqual(len(all), 4)
426 # We can't know which order SUB1 and SUB2 will appear in.
427 # Not flipped: TESTFN, SUB1, SUB11, SUB2
428 # flipped: TESTFN, SUB2, SUB1, SUB11
429 flipped = all[0][1][0] != "SUB1"
430 all[0][1].sort()
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000431 self.assertEqual(all[0], (walk_path, ["SUB1", "SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000432 self.assertEqual(all[1 + flipped], (sub1_path, ["SUB11"], ["tmp2"]))
433 self.assertEqual(all[2 + flipped], (sub11_path, [], []))
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000434 self.assertEqual(all[3 - 2 * flipped], sub2_tree)
Tim Petersc4e09402003-04-25 07:11:48 +0000435
436 # Prune the search.
437 all = []
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000438 for root, dirs, files in os.walk(walk_path):
Tim Petersc4e09402003-04-25 07:11:48 +0000439 all.append((root, dirs, files))
440 # Don't descend into SUB1.
441 if 'SUB1' in dirs:
442 # Note that this also mutates the dirs we appended to all!
443 dirs.remove('SUB1')
444 self.assertEqual(len(all), 2)
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000445 self.assertEqual(all[0], (walk_path, ["SUB2"], ["tmp1"]))
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000446 self.assertEqual(all[1], sub2_tree)
Tim Petersc4e09402003-04-25 07:11:48 +0000447
448 # Walk bottom-up.
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000449 all = list(os.walk(walk_path, topdown=False))
Tim Petersc4e09402003-04-25 07:11:48 +0000450 self.assertEqual(len(all), 4)
451 # We can't know which order SUB1 and SUB2 will appear in.
452 # Not flipped: SUB11, SUB1, SUB2, TESTFN
453 # flipped: SUB2, SUB11, SUB1, TESTFN
454 flipped = all[3][1][0] != "SUB1"
455 all[3][1].sort()
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000456 self.assertEqual(all[3], (walk_path, ["SUB1", "SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000457 self.assertEqual(all[flipped], (sub11_path, [], []))
458 self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"]))
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000459 self.assertEqual(all[2 - 2 * flipped], sub2_tree)
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000460
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000461 if hasattr(os, "symlink"):
462 # Walk, following symlinks.
463 for root, dirs, files in os.walk(walk_path, followlinks=True):
464 if root == link_path:
465 self.assertEqual(dirs, [])
466 self.assertEqual(files, ["tmp4"])
467 break
468 else:
469 self.fail("Didn't follow symlink with followlinks=True")
Tim Petersc4e09402003-04-25 07:11:48 +0000470
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000471 def tearDown(self):
Tim Petersc4e09402003-04-25 07:11:48 +0000472 # Tear everything down. This is a decent use for bottom-up on
473 # Windows, which doesn't have a recursive delete command. The
474 # (not so) subtlety is that rmdir will fail unless the dir's
475 # kids are removed first, so bottom up is essential.
Walter Dörwald21d3a322003-05-01 17:45:56 +0000476 for root, dirs, files in os.walk(test_support.TESTFN, topdown=False):
Tim Petersc4e09402003-04-25 07:11:48 +0000477 for name in files:
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000478 os.remove(os.path.join(root, name))
Tim Petersc4e09402003-04-25 07:11:48 +0000479 for name in dirs:
Žiga Seilnacht18ffe422007-04-04 18:38:47 +0000480 dirname = os.path.join(root, name)
Georg Brandlcae9f3d2007-03-21 09:10:29 +0000481 if not os.path.islink(dirname):
482 os.rmdir(dirname)
483 else:
484 os.remove(dirname)
Walter Dörwald21d3a322003-05-01 17:45:56 +0000485 os.rmdir(test_support.TESTFN)
Tim Petersc4e09402003-04-25 07:11:48 +0000486
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000487class MakedirTests (unittest.TestCase):
488 def setUp(self):
489 os.mkdir(test_support.TESTFN)
490
491 def test_makedir(self):
492 base = test_support.TESTFN
493 path = os.path.join(base, 'dir1', 'dir2', 'dir3')
494 os.makedirs(path) # Should work
495 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
496 os.makedirs(path)
497
498 # Try paths with a '.' in them
Benjamin Peterson5c8da862009-06-30 22:57:08 +0000499 self.assertRaises(OSError, os.makedirs, os.curdir)
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000500 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir)
501 os.makedirs(path)
502 path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4',
503 'dir5', 'dir6')
504 os.makedirs(path)
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000505
Tim Peters58eb11c2004-01-18 20:29:55 +0000506
507
508
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000509 def tearDown(self):
510 path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3',
511 'dir4', 'dir5', 'dir6')
512 # If the tests failed, the bottom-most directory ('../dir6')
513 # may not have been created, so we look for the outermost directory
514 # that exists.
515 while not os.path.exists(path) and path != test_support.TESTFN:
516 path = os.path.dirname(path)
517
518 os.removedirs(path)
519
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000520class DevNullTests (unittest.TestCase):
521 def test_devnull(self):
522 f = file(os.devnull, 'w')
523 f.write('hello')
524 f.close()
525 f = file(os.devnull, 'r')
Tim Peters4182cfd2004-06-08 20:34:34 +0000526 self.assertEqual(f.read(), '')
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000527 f.close()
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000528
Martin v. Löwisdc3883f2004-08-29 15:46:35 +0000529class URandomTests (unittest.TestCase):
Barry Warsaw1e13eb02012-02-20 20:42:21 -0500530
531 def test_urandom_length(self):
532 self.assertEqual(len(os.urandom(0)), 0)
533 self.assertEqual(len(os.urandom(1)), 1)
534 self.assertEqual(len(os.urandom(10)), 10)
535 self.assertEqual(len(os.urandom(100)), 100)
536 self.assertEqual(len(os.urandom(1000)), 1000)
537
538 def test_urandom_value(self):
539 data1 = os.urandom(16)
540 data2 = os.urandom(16)
541 self.assertNotEqual(data1, data2)
542
543 def get_urandom_subprocess(self, count):
544 code = '\n'.join((
545 'import os, sys',
546 'data = os.urandom(%s)' % count,
547 'sys.stdout.write(data)',
548 'sys.stdout.flush()'))
549 cmd_line = [sys.executable, '-c', code]
550 p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
551 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
552 out, err = p.communicate()
553 out = test_support.strip_python_stderr(out)
554 self.assertEqual(len(out), count)
555 return out
556
557 def test_urandom_subprocess(self):
558 data1 = self.get_urandom_subprocess(16)
559 data2 = self.get_urandom_subprocess(16)
560 self.assertNotEqual(data1, data2)
Martin v. Löwisdc3883f2004-08-29 15:46:35 +0000561
Matthias Klosee9fbf2b2010-03-19 14:45:06 +0000562 def test_execvpe_with_bad_arglist(self):
563 self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
564
Martin v. Löwis8e0d4942006-05-04 10:08:42 +0000565class Win32ErrorTests(unittest.TestCase):
566 def test_rename(self):
567 self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak")
568
569 def test_remove(self):
570 self.assertRaises(WindowsError, os.remove, test_support.TESTFN)
571
572 def test_chdir(self):
573 self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
574
Martin v. Löwisd4e3bb32006-05-06 16:32:54 +0000575 def test_mkdir(self):
Kristján Valur Jónssone20f54f2009-02-06 10:17:34 +0000576 f = open(test_support.TESTFN, "w")
577 try:
578 self.assertRaises(WindowsError, os.mkdir, test_support.TESTFN)
579 finally:
580 f.close()
581 os.unlink(test_support.TESTFN)
Martin v. Löwisd4e3bb32006-05-06 16:32:54 +0000582
583 def test_utime(self):
584 self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None)
585
Martin v. Löwisd4e3bb32006-05-06 16:32:54 +0000586 def test_chmod(self):
Kristján Valur Jónssone20f54f2009-02-06 10:17:34 +0000587 self.assertRaises(WindowsError, os.chmod, test_support.TESTFN, 0)
Martin v. Löwisd4e3bb32006-05-06 16:32:54 +0000588
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000589class TestInvalidFD(unittest.TestCase):
Kristján Valur Jónsson71ba2152009-01-15 22:40:03 +0000590 singles = ["fchdir", "fdopen", "dup", "fdatasync", "fstat",
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000591 "fstatvfs", "fsync", "tcgetpgrp", "ttyname"]
Kristján Valur Jónsson71ba2152009-01-15 22:40:03 +0000592 #singles.append("close")
593 #We omit close because it doesn'r raise an exception on some platforms
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000594 def get_single(f):
595 def helper(self):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000596 if hasattr(os, f):
597 self.check(getattr(os, f))
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000598 return helper
599 for f in singles:
600 locals()["test_"+f] = get_single(f)
601
Benjamin Peterson5539c782009-01-19 17:37:42 +0000602 def check(self, f, *args):
Benjamin Peterson1de05e92009-01-31 01:42:55 +0000603 try:
604 f(test_support.make_bad_fd(), *args)
605 except OSError as e:
606 self.assertEqual(e.errno, errno.EBADF)
607 else:
608 self.fail("%r didn't raise a OSError with a bad file descriptor"
609 % f)
Benjamin Peterson5539c782009-01-19 17:37:42 +0000610
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000611 def test_isatty(self):
Kristján Valur Jónsson4f69b7e2009-01-15 22:46:26 +0000612 if hasattr(os, "isatty"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000613 self.assertEqual(os.isatty(test_support.make_bad_fd()), False)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000614
615 def test_closerange(self):
Kristján Valur Jónsson4f69b7e2009-01-15 22:46:26 +0000616 if hasattr(os, "closerange"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000617 fd = test_support.make_bad_fd()
R. David Murray46ca2f22009-07-22 17:22:58 +0000618 # Make sure none of the descriptors we are about to close are
619 # currently valid (issue 6542).
620 for i in range(10):
621 try: os.fstat(fd+i)
622 except OSError:
623 pass
624 else:
625 break
626 if i < 2:
627 raise unittest.SkipTest(
628 "Unable to acquire a range of invalid file descriptors")
629 self.assertEqual(os.closerange(fd, fd + i-1), None)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000630
631 def test_dup2(self):
Kristján Valur Jónsson4f69b7e2009-01-15 22:46:26 +0000632 if hasattr(os, "dup2"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000633 self.check(os.dup2, 20)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000634
635 def test_fchmod(self):
636 if hasattr(os, "fchmod"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000637 self.check(os.fchmod, 0)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000638
639 def test_fchown(self):
640 if hasattr(os, "fchown"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000641 self.check(os.fchown, -1, -1)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000642
643 def test_fpathconf(self):
644 if hasattr(os, "fpathconf"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000645 self.check(os.fpathconf, "PC_NAME_MAX")
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000646
647 def test_ftruncate(self):
648 if hasattr(os, "ftruncate"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000649 self.check(os.ftruncate, 0)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000650
651 def test_lseek(self):
Kristján Valur Jónsson4f69b7e2009-01-15 22:46:26 +0000652 if hasattr(os, "lseek"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000653 self.check(os.lseek, 0, 0)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000654
655 def test_read(self):
Kristján Valur Jónsson4f69b7e2009-01-15 22:46:26 +0000656 if hasattr(os, "read"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000657 self.check(os.read, 1)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000658
659 def test_tcsetpgrpt(self):
660 if hasattr(os, "tcsetpgrp"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000661 self.check(os.tcsetpgrp, 0)
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000662
663 def test_write(self):
Kristján Valur Jónsson4f69b7e2009-01-15 22:46:26 +0000664 if hasattr(os, "write"):
Benjamin Peterson5539c782009-01-19 17:37:42 +0000665 self.check(os.write, " ")
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000666
Martin v. Löwis8e0d4942006-05-04 10:08:42 +0000667if sys.platform != 'win32':
668 class Win32ErrorTests(unittest.TestCase):
669 pass
670
Gregory P. Smith6d307932009-04-05 23:43:58 +0000671 class PosixUidGidTests(unittest.TestCase):
672 if hasattr(os, 'setuid'):
673 def test_setuid(self):
674 if os.getuid() != 0:
675 self.assertRaises(os.error, os.setuid, 0)
676 self.assertRaises(OverflowError, os.setuid, 1<<32)
677
678 if hasattr(os, 'setgid'):
679 def test_setgid(self):
680 if os.getuid() != 0:
681 self.assertRaises(os.error, os.setgid, 0)
682 self.assertRaises(OverflowError, os.setgid, 1<<32)
683
684 if hasattr(os, 'seteuid'):
685 def test_seteuid(self):
686 if os.getuid() != 0:
687 self.assertRaises(os.error, os.seteuid, 0)
688 self.assertRaises(OverflowError, os.seteuid, 1<<32)
689
690 if hasattr(os, 'setegid'):
691 def test_setegid(self):
692 if os.getuid() != 0:
693 self.assertRaises(os.error, os.setegid, 0)
694 self.assertRaises(OverflowError, os.setegid, 1<<32)
695
696 if hasattr(os, 'setreuid'):
697 def test_setreuid(self):
698 if os.getuid() != 0:
699 self.assertRaises(os.error, os.setreuid, 0, 0)
700 self.assertRaises(OverflowError, os.setreuid, 1<<32, 0)
701 self.assertRaises(OverflowError, os.setreuid, 0, 1<<32)
Gregory P. Smith467298c2010-03-06 07:35:19 +0000702
703 def test_setreuid_neg1(self):
704 # Needs to accept -1. We run this in a subprocess to avoid
705 # altering the test runner's process state (issue8045).
Gregory P. Smith467298c2010-03-06 07:35:19 +0000706 subprocess.check_call([
707 sys.executable, '-c',
708 'import os,sys;os.setreuid(-1,-1);sys.exit(0)'])
Gregory P. Smith6d307932009-04-05 23:43:58 +0000709
710 if hasattr(os, 'setregid'):
711 def test_setregid(self):
712 if os.getuid() != 0:
713 self.assertRaises(os.error, os.setregid, 0, 0)
714 self.assertRaises(OverflowError, os.setregid, 1<<32, 0)
715 self.assertRaises(OverflowError, os.setregid, 0, 1<<32)
Gregory P. Smith467298c2010-03-06 07:35:19 +0000716
717 def test_setregid_neg1(self):
718 # Needs to accept -1. We run this in a subprocess to avoid
719 # altering the test runner's process state (issue8045).
Gregory P. Smith467298c2010-03-06 07:35:19 +0000720 subprocess.check_call([
721 sys.executable, '-c',
722 'import os,sys;os.setregid(-1,-1);sys.exit(0)'])
Gregory P. Smith6d307932009-04-05 23:43:58 +0000723else:
724 class PosixUidGidTests(unittest.TestCase):
725 pass
726
Brian Curtine5aa8862010-04-02 23:26:06 +0000727@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
728class Win32KillTests(unittest.TestCase):
Brian Curtinb3dde132010-04-15 00:40:40 +0000729 def _kill(self, sig):
730 # Start sys.executable as a subprocess and communicate from the
731 # subprocess to the parent that the interpreter is ready. When it
732 # becomes ready, send *sig* via os.kill to the subprocess and check
733 # that the return code is equal to *sig*.
734 import ctypes
735 from ctypes import wintypes
736 import msvcrt
737
738 # Since we can't access the contents of the process' stdout until the
739 # process has exited, use PeekNamedPipe to see what's inside stdout
740 # without waiting. This is done so we can tell that the interpreter
741 # is started and running at a point where it could handle a signal.
742 PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe
743 PeekNamedPipe.restype = wintypes.BOOL
744 PeekNamedPipe.argtypes = (wintypes.HANDLE, # Pipe handle
745 ctypes.POINTER(ctypes.c_char), # stdout buf
746 wintypes.DWORD, # Buffer size
747 ctypes.POINTER(wintypes.DWORD), # bytes read
748 ctypes.POINTER(wintypes.DWORD), # bytes avail
749 ctypes.POINTER(wintypes.DWORD)) # bytes left
750 msg = "running"
751 proc = subprocess.Popen([sys.executable, "-c",
752 "import sys;"
753 "sys.stdout.write('{}');"
754 "sys.stdout.flush();"
755 "input()".format(msg)],
756 stdout=subprocess.PIPE,
757 stderr=subprocess.PIPE,
758 stdin=subprocess.PIPE)
Brian Curtinf4f0c8b2010-11-05 15:31:20 +0000759 self.addCleanup(proc.stdout.close)
760 self.addCleanup(proc.stderr.close)
761 self.addCleanup(proc.stdin.close)
Brian Curtinb3dde132010-04-15 00:40:40 +0000762
Brian Curtin83cba052010-05-28 15:49:21 +0000763 count, max = 0, 100
764 while count < max and proc.poll() is None:
765 # Create a string buffer to store the result of stdout from the pipe
766 buf = ctypes.create_string_buffer(len(msg))
767 # Obtain the text currently in proc.stdout
768 # Bytes read/avail/left are left as NULL and unused
769 rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()),
770 buf, ctypes.sizeof(buf), None, None, None)
771 self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
772 if buf.value:
773 self.assertEqual(msg, buf.value)
774 break
775 time.sleep(0.1)
776 count += 1
777 else:
778 self.fail("Did not receive communication from the subprocess")
Brian Curtinb3dde132010-04-15 00:40:40 +0000779
Brian Curtine5aa8862010-04-02 23:26:06 +0000780 os.kill(proc.pid, sig)
781 self.assertEqual(proc.wait(), sig)
782
783 def test_kill_sigterm(self):
784 # SIGTERM doesn't mean anything special, but make sure it works
Brian Curtinb3dde132010-04-15 00:40:40 +0000785 self._kill(signal.SIGTERM)
Brian Curtine5aa8862010-04-02 23:26:06 +0000786
787 def test_kill_int(self):
788 # os.kill on Windows can take an int which gets set as the exit code
Brian Curtinb3dde132010-04-15 00:40:40 +0000789 self._kill(100)
Brian Curtine5aa8862010-04-02 23:26:06 +0000790
791 def _kill_with_event(self, event, name):
Hirokazu Yamamoto1f504f12010-10-08 09:41:13 +0000792 tagname = "test_os_%s" % uuid.uuid1()
793 m = mmap.mmap(-1, 1, tagname)
794 m[0] = '0'
Brian Curtine5aa8862010-04-02 23:26:06 +0000795 # Run a script which has console control handling enabled.
796 proc = subprocess.Popen([sys.executable,
797 os.path.join(os.path.dirname(__file__),
Hirokazu Yamamoto1f504f12010-10-08 09:41:13 +0000798 "win_console_handler.py"), tagname],
Brian Curtine5aa8862010-04-02 23:26:06 +0000799 creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
800 # Let the interpreter startup before we send signals. See #3137.
Hirokazu Yamamoto1f504f12010-10-08 09:41:13 +0000801 count, max = 0, 20
802 while count < max and proc.poll() is None:
Brian Curtindbf8e832010-11-05 15:28:19 +0000803 if m[0] == '1':
Hirokazu Yamamoto1f504f12010-10-08 09:41:13 +0000804 break
805 time.sleep(0.5)
806 count += 1
807 else:
808 self.fail("Subprocess didn't finish initialization")
Brian Curtine5aa8862010-04-02 23:26:06 +0000809 os.kill(proc.pid, event)
810 # proc.send_signal(event) could also be done here.
811 # Allow time for the signal to be passed and the process to exit.
Brian Curtinfce1d312010-04-05 19:04:23 +0000812 time.sleep(0.5)
Brian Curtine5aa8862010-04-02 23:26:06 +0000813 if not proc.poll():
814 # Forcefully kill the process if we weren't able to signal it.
815 os.kill(proc.pid, signal.SIGINT)
816 self.fail("subprocess did not stop on {}".format(name))
817
818 @unittest.skip("subprocesses aren't inheriting CTRL+C property")
819 def test_CTRL_C_EVENT(self):
820 from ctypes import wintypes
821 import ctypes
822
823 # Make a NULL value by creating a pointer with no argument.
824 NULL = ctypes.POINTER(ctypes.c_int)()
825 SetConsoleCtrlHandler = ctypes.windll.kernel32.SetConsoleCtrlHandler
826 SetConsoleCtrlHandler.argtypes = (ctypes.POINTER(ctypes.c_int),
827 wintypes.BOOL)
828 SetConsoleCtrlHandler.restype = wintypes.BOOL
829
830 # Calling this with NULL and FALSE causes the calling process to
831 # handle CTRL+C, rather than ignore it. This property is inherited
832 # by subprocesses.
833 SetConsoleCtrlHandler(NULL, 0)
834
835 self._kill_with_event(signal.CTRL_C_EVENT, "CTRL_C_EVENT")
836
837 def test_CTRL_BREAK_EVENT(self):
838 self._kill_with_event(signal.CTRL_BREAK_EVENT, "CTRL_BREAK_EVENT")
839
840
Fred Drake2e2be372001-09-20 21:33:42 +0000841def test_main():
Walter Dörwald21d3a322003-05-01 17:45:56 +0000842 test_support.run_unittest(
Martin v. Löwisee1e06d2006-07-02 18:44:00 +0000843 FileTests,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000844 TemporaryFileTests,
845 StatAttributeTests,
846 EnvironTests,
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000847 WalkTests,
848 MakedirTests,
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000849 DevNullTests,
Martin v. Löwis8e0d4942006-05-04 10:08:42 +0000850 URandomTests,
Kristján Valur Jónsson1c62b652009-01-12 18:09:27 +0000851 Win32ErrorTests,
Gregory P. Smith6d307932009-04-05 23:43:58 +0000852 TestInvalidFD,
Brian Curtine5aa8862010-04-02 23:26:06 +0000853 PosixUidGidTests,
854 Win32KillTests
Walter Dörwald21d3a322003-05-01 17:45:56 +0000855 )
Fred Drake2e2be372001-09-20 21:33:42 +0000856
857if __name__ == "__main__":
858 test_main()