blob: bff4f0bdea090bdddd0f1f3d44a8769ce10899dd [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 Peterson5c6d7872009-02-06 02:40:07 +00006import errno
Fred Drake38c2ef02001-07-17 20:52:51 +00007import unittest
Jeremy Hyltona7fc21b2001-08-20 20:10:01 +00008import warnings
Thomas Wouters477c8d52006-05-27 19:21:47 +00009import sys
Martin v. Löwis011e8422009-05-05 04:43:17 +000010import shutil
Benjamin Petersonee8712c2008-05-20 21:35:26 +000011from test import support
Georg Brandl2daf6ae2012-02-20 19:54:16 +010012from test.script_helper import assert_python_ok
Fred Drake38c2ef02001-07-17 20:52:51 +000013
Mark Dickinson466e9262010-04-16 16:32:49 +000014# Detect whether we're on a Linux system that uses the (now outdated
15# and unmaintained) linuxthreads threading library. There's an issue
16# when combining linuxthreads with a failed execv call: see
17# http://bugs.python.org/issue4970.
18if (hasattr(os, "confstr_names") and
19 "CS_GNU_LIBPTHREAD_VERSION" in os.confstr_names):
20 libpthread = os.confstr("CS_GNU_LIBPTHREAD_VERSION")
21 USING_LINUXTHREADS= libpthread.startswith("linuxthreads")
22else:
23 USING_LINUXTHREADS= False
24
Thomas Wouters0e3f5912006-08-11 14:57:12 +000025# Tests creating TESTFN
26class FileTests(unittest.TestCase):
27 def setUp(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +000028 if os.path.exists(support.TESTFN):
29 os.unlink(support.TESTFN)
Thomas Wouters0e3f5912006-08-11 14:57:12 +000030 tearDown = setUp
31
32 def test_access(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +000033 f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
Thomas Wouters0e3f5912006-08-11 14:57:12 +000034 os.close(f)
Georg Brandlab91fde2009-08-13 08:51:18 +000035 self.assertTrue(os.access(support.TESTFN, os.W_OK))
Thomas Wouters0e3f5912006-08-11 14:57:12 +000036
Christian Heimesfdab48e2008-01-20 09:06:41 +000037 def test_closerange(self):
Antoine Pitroub9ee06c2008-08-16 22:03:17 +000038 first = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
39 # We must allocate two consecutive file descriptors, otherwise
40 # it will mess up other file descriptors (perhaps even the three
41 # standard ones).
42 second = os.dup(first)
43 try:
44 retries = 0
45 while second != first + 1:
46 os.close(first)
47 retries += 1
48 if retries > 10:
49 # XXX test skipped
Benjamin Petersonfa0d7032009-06-01 22:42:33 +000050 self.skipTest("couldn't allocate two consecutive fds")
Antoine Pitroub9ee06c2008-08-16 22:03:17 +000051 first, second = second, os.dup(second)
52 finally:
53 os.close(second)
Christian Heimesfdab48e2008-01-20 09:06:41 +000054 # close a fd that is open, and one that isn't
Antoine Pitroub9ee06c2008-08-16 22:03:17 +000055 os.closerange(first, first + 2)
Antoine Pitrou9cadb1b2008-09-15 23:02:56 +000056 self.assertRaises(OSError, os.write, first, b"a")
Thomas Wouters0e3f5912006-08-11 14:57:12 +000057
Hirokazu Yamamoto4c19e6e2008-09-08 23:41:21 +000058 def test_rename(self):
59 path = support.TESTFN
60 old = sys.getrefcount(path)
61 self.assertRaises(TypeError, os.rename, path, 0)
62 new = sys.getrefcount(path)
63 self.assertEqual(old, new)
64
Antoine Pitrou9cadb1b2008-09-15 23:02:56 +000065 def test_read(self):
66 with open(support.TESTFN, "w+b") as fobj:
67 fobj.write(b"spam")
68 fobj.flush()
69 fd = fobj.fileno()
70 os.lseek(fd, 0, 0)
71 s = os.read(fd, 4)
72 self.assertEqual(type(s), bytes)
73 self.assertEqual(s, b"spam")
74
75 def test_write(self):
76 # os.write() accepts bytes- and buffer-like objects but not strings
77 fd = os.open(support.TESTFN, os.O_CREAT | os.O_WRONLY)
78 self.assertRaises(TypeError, os.write, fd, "beans")
79 os.write(fd, b"bacon\n")
80 os.write(fd, bytearray(b"eggs\n"))
81 os.write(fd, memoryview(b"spam\n"))
82 os.close(fd)
83 with open(support.TESTFN, "rb") as fobj:
Antoine Pitroud62269f2008-09-15 23:54:52 +000084 self.assertEqual(fobj.read().splitlines(),
85 [b"bacon", b"eggs", b"spam"])
Antoine Pitrou9cadb1b2008-09-15 23:02:56 +000086
87
Christian Heimesdd15f6c2008-03-16 00:07:10 +000088class TemporaryFileTests(unittest.TestCase):
89 def setUp(self):
90 self.files = []
Benjamin Petersonee8712c2008-05-20 21:35:26 +000091 os.mkdir(support.TESTFN)
Christian Heimesdd15f6c2008-03-16 00:07:10 +000092
93 def tearDown(self):
94 for name in self.files:
95 os.unlink(name)
Benjamin Petersonee8712c2008-05-20 21:35:26 +000096 os.rmdir(support.TESTFN)
Christian Heimesdd15f6c2008-03-16 00:07:10 +000097
98 def check_tempfile(self, name):
99 # make sure it doesn't already exist:
Georg Brandlab91fde2009-08-13 08:51:18 +0000100 self.assertFalse(os.path.exists(name),
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000101 "file already exists for temporary file")
102 # make sure we can create the file
103 open(name, "w")
104 self.files.append(name)
105
106 def test_tempnam(self):
107 if not hasattr(os, "tempnam"):
108 return
109 warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
110 r"test_os$")
111 self.check_tempfile(os.tempnam())
112
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000113 name = os.tempnam(support.TESTFN)
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000114 self.check_tempfile(name)
115
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000116 name = os.tempnam(support.TESTFN, "pfx")
Georg Brandlab91fde2009-08-13 08:51:18 +0000117 self.assertTrue(os.path.basename(name)[:3] == "pfx")
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000118 self.check_tempfile(name)
119
120 def test_tmpfile(self):
121 if not hasattr(os, "tmpfile"):
122 return
123 # As with test_tmpnam() below, the Windows implementation of tmpfile()
124 # attempts to create a file in the root directory of the current drive.
125 # On Vista and Server 2008, this test will always fail for normal users
126 # as writing to the root directory requires elevated privileges. With
127 # XP and below, the semantics of tmpfile() are the same, but the user
128 # running the test is more likely to have administrative privileges on
129 # their account already. If that's the case, then os.tmpfile() should
130 # work. In order to make this test as useful as possible, rather than
131 # trying to detect Windows versions or whether or not the user has the
132 # right permissions, just try and create a file in the root directory
133 # and see if it raises a 'Permission denied' OSError. If it does, then
134 # test that a subsequent call to os.tmpfile() raises the same error. If
135 # it doesn't, assume we're on XP or below and the user running the test
136 # has administrative privileges, and proceed with the test as normal.
137 if sys.platform == 'win32':
138 name = '\\python_test_os_test_tmpfile.txt'
139 if os.path.exists(name):
140 os.remove(name)
141 try:
142 fp = open(name, 'w')
143 except IOError as first:
144 # open() failed, assert tmpfile() fails in the same way.
145 # Although open() raises an IOError and os.tmpfile() raises an
146 # OSError(), 'args' will be (13, 'Permission denied') in both
147 # cases.
148 try:
149 fp = os.tmpfile()
150 except OSError as second:
151 self.assertEqual(first.args, second.args)
152 else:
153 self.fail("expected os.tmpfile() to raise OSError")
154 return
155 else:
156 # open() worked, therefore, tmpfile() should work. Close our
157 # dummy file and proceed with the test as normal.
158 fp.close()
159 os.remove(name)
160
161 fp = os.tmpfile()
162 fp.write("foobar")
163 fp.seek(0,0)
164 s = fp.read()
165 fp.close()
Georg Brandlab91fde2009-08-13 08:51:18 +0000166 self.assertTrue(s == "foobar")
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000167
168 def test_tmpnam(self):
169 import sys
170 if not hasattr(os, "tmpnam"):
171 return
172 warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
173 r"test_os$")
174 name = os.tmpnam()
175 if sys.platform in ("win32",):
176 # The Windows tmpnam() seems useless. From the MS docs:
177 #
178 # The character string that tmpnam creates consists of
179 # the path prefix, defined by the entry P_tmpdir in the
180 # file STDIO.H, followed by a sequence consisting of the
181 # digit characters '0' through '9'; the numerical value
182 # of this string is in the range 1 - 65,535. Changing the
183 # definitions of L_tmpnam or P_tmpdir in STDIO.H does not
184 # change the operation of tmpnam.
185 #
186 # The really bizarre part is that, at least under MSVC6,
187 # P_tmpdir is "\\". That is, the path returned refers to
188 # the root of the current drive. That's a terrible place to
189 # put temp files, and, depending on privileges, the user
190 # may not even be able to open a file in the root directory.
Georg Brandlab91fde2009-08-13 08:51:18 +0000191 self.assertFalse(os.path.exists(name),
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000192 "file already exists for temporary file")
193 else:
194 self.check_tempfile(name)
195
Amaury Forgeot d'Arce2e36ba2008-08-01 00:14:22 +0000196 def fdopen_helper(self, *args):
197 fd = os.open(support.TESTFN, os.O_RDONLY)
198 fp2 = os.fdopen(fd, *args)
199 fp2.close()
200
201 def test_fdopen(self):
202 self.fdopen_helper()
203 self.fdopen_helper('r')
204 self.fdopen_helper('r', 100)
205
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000206# Test attributes on return values from os.*stat* family.
207class StatAttributeTests(unittest.TestCase):
208 def setUp(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000209 os.mkdir(support.TESTFN)
210 self.fname = os.path.join(support.TESTFN, "f1")
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000211 f = open(self.fname, 'wb')
Guido van Rossum26d95c32007-08-27 23:18:54 +0000212 f.write(b"ABC")
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000213 f.close()
Tim Peterse0c446b2001-10-18 21:57:37 +0000214
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000215 def tearDown(self):
216 os.unlink(self.fname)
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000217 os.rmdir(support.TESTFN)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000218
219 def test_stat_attributes(self):
220 if not hasattr(os, "stat"):
221 return
222
223 import stat
224 result = os.stat(self.fname)
225
226 # Make sure direct access works
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000227 self.assertEqual(result[stat.ST_SIZE], 3)
228 self.assertEqual(result.st_size, 3)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000229
230 import sys
231
232 # Make sure all the attributes are there
233 members = dir(result)
234 for name in dir(stat):
235 if name[:3] == 'ST_':
236 attr = name.lower()
Martin v. Löwis4d394df2005-01-23 09:19:22 +0000237 if name.endswith("TIME"):
238 def trunc(x): return int(x)
239 else:
240 def trunc(x): return x
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000241 self.assertEqual(trunc(getattr(result, attr)),
242 result[getattr(stat, name)])
Georg Brandlab91fde2009-08-13 08:51:18 +0000243 self.assertTrue(attr in members)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000244
245 try:
246 result[200]
247 self.fail("No exception thrown")
248 except IndexError:
249 pass
250
251 # Make sure that assignment fails
252 try:
253 result.st_mode = 1
254 self.fail("No exception thrown")
Collin Winter42dae6a2007-03-28 21:44:53 +0000255 except AttributeError:
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000256 pass
257
258 try:
259 result.st_rdev = 1
260 self.fail("No exception thrown")
Guido van Rossum1fff8782001-10-18 21:19:31 +0000261 except (AttributeError, TypeError):
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000262 pass
263
264 try:
265 result.parrot = 1
266 self.fail("No exception thrown")
267 except AttributeError:
268 pass
269
270 # Use the stat_result constructor with a too-short tuple.
271 try:
272 result2 = os.stat_result((10,))
273 self.fail("No exception thrown")
274 except TypeError:
275 pass
276
Ezio Melotti42da6632011-03-15 05:18:48 +0200277 # Use the constructor with a too-long tuple.
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000278 try:
279 result2 = os.stat_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14))
280 except TypeError:
281 pass
282
Tim Peterse0c446b2001-10-18 21:57:37 +0000283
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000284 def test_statvfs_attributes(self):
285 if not hasattr(os, "statvfs"):
286 return
287
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000288 try:
289 result = os.statvfs(self.fname)
Guido van Rossumb940e112007-01-10 16:19:56 +0000290 except OSError as e:
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000291 # On AtheOS, glibc always returns ENOSYS
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000292 if e.errno == errno.ENOSYS:
293 return
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000294
295 # Make sure direct access works
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000296 self.assertEqual(result.f_bfree, result[3])
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000297
Brett Cannoncfaf10c2008-05-16 00:45:35 +0000298 # Make sure all the attributes are there.
299 members = ('bsize', 'frsize', 'blocks', 'bfree', 'bavail', 'files',
300 'ffree', 'favail', 'flag', 'namemax')
301 for value, member in enumerate(members):
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000302 self.assertEqual(getattr(result, 'f_' + member), result[value])
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000303
304 # Make sure that assignment really fails
305 try:
306 result.f_bfree = 1
307 self.fail("No exception thrown")
Collin Winter42dae6a2007-03-28 21:44:53 +0000308 except AttributeError:
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000309 pass
310
311 try:
312 result.parrot = 1
313 self.fail("No exception thrown")
314 except AttributeError:
315 pass
316
317 # Use the constructor with a too-short tuple.
318 try:
319 result2 = os.statvfs_result((10,))
320 self.fail("No exception thrown")
321 except TypeError:
322 pass
323
Ezio Melotti42da6632011-03-15 05:18:48 +0200324 # Use the constructor with a too-long tuple.
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000325 try:
326 result2 = os.statvfs_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14))
327 except TypeError:
328 pass
Fred Drake38c2ef02001-07-17 20:52:51 +0000329
Thomas Wouters89f507f2006-12-13 04:49:30 +0000330 def test_utime_dir(self):
331 delta = 1000000
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000332 st = os.stat(support.TESTFN)
Thomas Wouters89f507f2006-12-13 04:49:30 +0000333 # round to int, because some systems may support sub-second
334 # time stamps in stat, but not in utime.
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000335 os.utime(support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
336 st2 = os.stat(support.TESTFN)
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000337 self.assertEqual(st2.st_mtime, int(st.st_mtime-delta))
Thomas Wouters89f507f2006-12-13 04:49:30 +0000338
339 # Restrict test to Win32, since there is no guarantee other
340 # systems support centiseconds
341 if sys.platform == 'win32':
Thomas Wouters47b49bf2007-08-30 22:15:33 +0000342 def get_file_system(path):
Hirokazu Yamamoto5ef6d182008-08-20 04:17:24 +0000343 root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'
Thomas Wouters47b49bf2007-08-30 22:15:33 +0000344 import ctypes
Hirokazu Yamamotoca765d52008-08-20 16:18:19 +0000345 kernel32 = ctypes.windll.kernel32
Hirokazu Yamamoto5ef6d182008-08-20 04:17:24 +0000346 buf = ctypes.create_unicode_buffer("", 100)
Hirokazu Yamamotoca765d52008-08-20 16:18:19 +0000347 if kernel32.GetVolumeInformationW(root, None, 0, None, None, None, buf, len(buf)):
Thomas Wouters47b49bf2007-08-30 22:15:33 +0000348 return buf.value
349
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000350 if get_file_system(support.TESTFN) == "NTFS":
Thomas Wouters47b49bf2007-08-30 22:15:33 +0000351 def test_1565150(self):
352 t1 = 1159195039.25
353 os.utime(self.fname, (t1, t1))
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000354 self.assertEqual(os.stat(self.fname).st_mtime, t1)
Thomas Wouters89f507f2006-12-13 04:49:30 +0000355
Amaury Forgeot d'Arc32e8aab2011-01-03 00:40:04 +0000356 def test_large_time(self):
357 t1 = 5000000000 # some day in 2128
358 os.utime(self.fname, (t1, t1))
359 self.assertEqual(os.stat(self.fname).st_mtime, t1)
360
Guido van Rossumd8faa362007-04-27 19:54:29 +0000361 def test_1686475(self):
362 # Verify that an open file can be stat'ed
363 try:
364 os.stat(r"c:\pagefile.sys")
365 except WindowsError as e:
Benjamin Petersonc4fe6f32008-08-19 18:57:56 +0000366 if e.errno == 2: # file does not exist; cannot run test
Guido van Rossumd8faa362007-04-27 19:54:29 +0000367 return
368 self.fail("Could not stat pagefile.sys")
369
Walter Dörwald0a6d0ff2004-05-31 16:29:04 +0000370from test import mapping_tests
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000371
Walter Dörwald0a6d0ff2004-05-31 16:29:04 +0000372class EnvironTests(mapping_tests.BasicTestMappingProtocol):
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000373 """check that os.environ object conform to mapping protocol"""
Walter Dörwald118f9312004-06-02 18:42:25 +0000374 type2test = None
Christian Heimes90333392007-11-01 19:08:42 +0000375
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000376 def setUp(self):
377 self.__save = dict(os.environ)
Christian Heimes90333392007-11-01 19:08:42 +0000378 for key, value in self._reference().items():
379 os.environ[key] = value
380
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000381 def tearDown(self):
382 os.environ.clear()
383 os.environ.update(self.__save)
384
Christian Heimes90333392007-11-01 19:08:42 +0000385 def _reference(self):
386 return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
387
388 def _empty_mapping(self):
389 os.environ.clear()
390 return os.environ
391
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000392 # Bug 1110478
Martin v. Löwis5510f652005-02-17 21:23:20 +0000393 def test_update2(self):
Christian Heimes90333392007-11-01 19:08:42 +0000394 os.environ.clear()
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000395 if os.path.exists("/bin/sh"):
396 os.environ.update(HELLO="World")
Brian Curtin32105f42010-10-30 21:27:07 +0000397 with os.popen("/bin/sh -c 'echo $HELLO'") as popen:
398 value = popen.read().strip()
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000399 self.assertEqual(value, "World")
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000400
Christian Heimes1a13d592007-11-08 14:16:55 +0000401 def test_os_popen_iter(self):
402 if os.path.exists("/bin/sh"):
Brian Curtin32105f42010-10-30 21:27:07 +0000403 with os.popen(
404 "/bin/sh -c 'echo \"line1\nline2\nline3\"'") as popen:
405 it = iter(popen)
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000406 self.assertEqual(next(it), "line1\n")
407 self.assertEqual(next(it), "line2\n")
408 self.assertEqual(next(it), "line3\n")
Brian Curtin32105f42010-10-30 21:27:07 +0000409 self.assertRaises(StopIteration, next, it)
Christian Heimes1a13d592007-11-08 14:16:55 +0000410
Guido van Rossum67aca9e2007-06-13 21:51:27 +0000411 # Verify environ keys and values from the OS are of the
412 # correct str type.
413 def test_keyvalue_types(self):
414 for key, val in os.environ.items():
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000415 self.assertEqual(type(key), str)
416 self.assertEqual(type(val), str)
Guido van Rossum67aca9e2007-06-13 21:51:27 +0000417
Christian Heimes90333392007-11-01 19:08:42 +0000418 def test_items(self):
419 for key, value in self._reference().items():
420 self.assertEqual(os.environ.get(key), value)
421
Ezio Melottid2a577d2010-02-22 16:01:22 +0000422 # Issue 7310
423 def test___repr__(self):
424 """Check that the repr() of os.environ looks like environ({...})."""
425 env = os.environ
426 self.assertTrue(isinstance(env.data, dict))
427 self.assertEqual(repr(env), 'environ({!r})'.format(env.data))
428
429
Tim Petersc4e09402003-04-25 07:11:48 +0000430class WalkTests(unittest.TestCase):
431 """Tests for os.walk()."""
432
433 def test_traversal(self):
434 import os
435 from os.path import join
436
437 # Build:
Guido van Rossumd8faa362007-04-27 19:54:29 +0000438 # TESTFN/
439 # TEST1/ a file kid and two directory kids
Tim Petersc4e09402003-04-25 07:11:48 +0000440 # tmp1
441 # SUB1/ a file kid and a directory kid
Guido van Rossumd8faa362007-04-27 19:54:29 +0000442 # tmp2
443 # SUB11/ no kids
444 # SUB2/ a file kid and a dirsymlink kid
445 # tmp3
446 # link/ a symlink to TESTFN.2
447 # TEST2/
448 # tmp4 a lone file
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000449 walk_path = join(support.TESTFN, "TEST1")
Guido van Rossumd8faa362007-04-27 19:54:29 +0000450 sub1_path = join(walk_path, "SUB1")
Tim Petersc4e09402003-04-25 07:11:48 +0000451 sub11_path = join(sub1_path, "SUB11")
Guido van Rossumd8faa362007-04-27 19:54:29 +0000452 sub2_path = join(walk_path, "SUB2")
453 tmp1_path = join(walk_path, "tmp1")
Tim Petersc4e09402003-04-25 07:11:48 +0000454 tmp2_path = join(sub1_path, "tmp2")
455 tmp3_path = join(sub2_path, "tmp3")
Guido van Rossumd8faa362007-04-27 19:54:29 +0000456 link_path = join(sub2_path, "link")
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000457 t2_path = join(support.TESTFN, "TEST2")
458 tmp4_path = join(support.TESTFN, "TEST2", "tmp4")
Tim Petersc4e09402003-04-25 07:11:48 +0000459
460 # Create stuff.
461 os.makedirs(sub11_path)
462 os.makedirs(sub2_path)
Guido van Rossumd8faa362007-04-27 19:54:29 +0000463 os.makedirs(t2_path)
464 for path in tmp1_path, tmp2_path, tmp3_path, tmp4_path:
Alex Martelli01c77c62006-08-24 02:58:11 +0000465 f = open(path, "w")
Tim Petersc4e09402003-04-25 07:11:48 +0000466 f.write("I'm " + path + " and proud of it. Blame test_os.\n")
467 f.close()
Guido van Rossumd8faa362007-04-27 19:54:29 +0000468 if hasattr(os, "symlink"):
469 os.symlink(os.path.abspath(t2_path), link_path)
470 sub2_tree = (sub2_path, ["link"], ["tmp3"])
471 else:
472 sub2_tree = (sub2_path, [], ["tmp3"])
Tim Petersc4e09402003-04-25 07:11:48 +0000473
474 # Walk top-down.
Guido van Rossumd8faa362007-04-27 19:54:29 +0000475 all = list(os.walk(walk_path))
Tim Petersc4e09402003-04-25 07:11:48 +0000476 self.assertEqual(len(all), 4)
477 # We can't know which order SUB1 and SUB2 will appear in.
478 # Not flipped: TESTFN, SUB1, SUB11, SUB2
479 # flipped: TESTFN, SUB2, SUB1, SUB11
480 flipped = all[0][1][0] != "SUB1"
481 all[0][1].sort()
Guido van Rossumd8faa362007-04-27 19:54:29 +0000482 self.assertEqual(all[0], (walk_path, ["SUB1", "SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000483 self.assertEqual(all[1 + flipped], (sub1_path, ["SUB11"], ["tmp2"]))
484 self.assertEqual(all[2 + flipped], (sub11_path, [], []))
Guido van Rossumd8faa362007-04-27 19:54:29 +0000485 self.assertEqual(all[3 - 2 * flipped], sub2_tree)
Tim Petersc4e09402003-04-25 07:11:48 +0000486
487 # Prune the search.
488 all = []
Guido van Rossumd8faa362007-04-27 19:54:29 +0000489 for root, dirs, files in os.walk(walk_path):
Tim Petersc4e09402003-04-25 07:11:48 +0000490 all.append((root, dirs, files))
491 # Don't descend into SUB1.
492 if 'SUB1' in dirs:
493 # Note that this also mutates the dirs we appended to all!
494 dirs.remove('SUB1')
495 self.assertEqual(len(all), 2)
Guido van Rossumd8faa362007-04-27 19:54:29 +0000496 self.assertEqual(all[0], (walk_path, ["SUB2"], ["tmp1"]))
497 self.assertEqual(all[1], sub2_tree)
Tim Petersc4e09402003-04-25 07:11:48 +0000498
499 # Walk bottom-up.
Guido van Rossumd8faa362007-04-27 19:54:29 +0000500 all = list(os.walk(walk_path, topdown=False))
Tim Petersc4e09402003-04-25 07:11:48 +0000501 self.assertEqual(len(all), 4)
502 # We can't know which order SUB1 and SUB2 will appear in.
503 # Not flipped: SUB11, SUB1, SUB2, TESTFN
504 # flipped: SUB2, SUB11, SUB1, TESTFN
505 flipped = all[3][1][0] != "SUB1"
506 all[3][1].sort()
Guido van Rossumd8faa362007-04-27 19:54:29 +0000507 self.assertEqual(all[3], (walk_path, ["SUB1", "SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000508 self.assertEqual(all[flipped], (sub11_path, [], []))
509 self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"]))
Guido van Rossumd8faa362007-04-27 19:54:29 +0000510 self.assertEqual(all[2 - 2 * flipped], sub2_tree)
Tim Petersc4e09402003-04-25 07:11:48 +0000511
Guido van Rossumd8faa362007-04-27 19:54:29 +0000512 if hasattr(os, "symlink"):
513 # Walk, following symlinks.
514 for root, dirs, files in os.walk(walk_path, followlinks=True):
515 if root == link_path:
516 self.assertEqual(dirs, [])
517 self.assertEqual(files, ["tmp4"])
518 break
519 else:
520 self.fail("Didn't follow symlink with followlinks=True")
521
522 def tearDown(self):
Tim Petersc4e09402003-04-25 07:11:48 +0000523 # Tear everything down. This is a decent use for bottom-up on
524 # Windows, which doesn't have a recursive delete command. The
525 # (not so) subtlety is that rmdir will fail unless the dir's
526 # kids are removed first, so bottom up is essential.
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000527 for root, dirs, files in os.walk(support.TESTFN, topdown=False):
Tim Petersc4e09402003-04-25 07:11:48 +0000528 for name in files:
Guido van Rossumd8faa362007-04-27 19:54:29 +0000529 os.remove(os.path.join(root, name))
Tim Petersc4e09402003-04-25 07:11:48 +0000530 for name in dirs:
Guido van Rossumd8faa362007-04-27 19:54:29 +0000531 dirname = os.path.join(root, name)
532 if not os.path.islink(dirname):
533 os.rmdir(dirname)
534 else:
535 os.remove(dirname)
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000536 os.rmdir(support.TESTFN)
Tim Petersc4e09402003-04-25 07:11:48 +0000537
Guido van Rossume7ba4952007-06-06 23:52:48 +0000538class MakedirTests(unittest.TestCase):
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000539 def setUp(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000540 os.mkdir(support.TESTFN)
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000541
542 def test_makedir(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000543 base = support.TESTFN
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000544 path = os.path.join(base, 'dir1', 'dir2', 'dir3')
545 os.makedirs(path) # Should work
546 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
547 os.makedirs(path)
548
549 # Try paths with a '.' in them
Georg Brandlab91fde2009-08-13 08:51:18 +0000550 self.assertRaises(OSError, os.makedirs, os.curdir)
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000551 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir)
552 os.makedirs(path)
553 path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4',
554 'dir5', 'dir6')
555 os.makedirs(path)
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000556
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000557 def tearDown(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000558 path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000559 'dir4', 'dir5', 'dir6')
560 # If the tests failed, the bottom-most directory ('../dir6')
561 # may not have been created, so we look for the outermost directory
562 # that exists.
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000563 while not os.path.exists(path) and path != support.TESTFN:
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000564 path = os.path.dirname(path)
565
566 os.removedirs(path)
567
Guido van Rossume7ba4952007-06-06 23:52:48 +0000568class DevNullTests(unittest.TestCase):
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000569 def test_devnull(self):
Alex Martelli01c77c62006-08-24 02:58:11 +0000570 f = open(os.devnull, 'w')
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000571 f.write('hello')
572 f.close()
Alex Martelli01c77c62006-08-24 02:58:11 +0000573 f = open(os.devnull, 'r')
Tim Peters4182cfd2004-06-08 20:34:34 +0000574 self.assertEqual(f.read(), '')
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000575 f.close()
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000576
Guido van Rossume7ba4952007-06-06 23:52:48 +0000577class URandomTests(unittest.TestCase):
Georg Brandl2daf6ae2012-02-20 19:54:16 +0100578 def test_urandom_length(self):
579 self.assertEqual(len(os.urandom(0)), 0)
580 self.assertEqual(len(os.urandom(1)), 1)
581 self.assertEqual(len(os.urandom(10)), 10)
582 self.assertEqual(len(os.urandom(100)), 100)
583 self.assertEqual(len(os.urandom(1000)), 1000)
584
585 def test_urandom_value(self):
586 data1 = os.urandom(16)
587 data2 = os.urandom(16)
588 self.assertNotEqual(data1, data2)
589
590 def get_urandom_subprocess(self, count):
591 code = '\n'.join((
592 'import os, sys',
593 'data = os.urandom(%s)' % count,
594 'sys.stdout.buffer.write(data)',
595 'sys.stdout.buffer.flush()'))
596 out = assert_python_ok('-c', code)
597 stdout = out[1]
598 self.assertEqual(len(stdout), 16)
599 return stdout
600
601 def test_urandom_subprocess(self):
602 data1 = self.get_urandom_subprocess(16)
603 data2 = self.get_urandom_subprocess(16)
604 self.assertNotEqual(data1, data2)
Martin v. Löwisdc3883f2004-08-29 15:46:35 +0000605
Guido van Rossume7ba4952007-06-06 23:52:48 +0000606class ExecTests(unittest.TestCase):
Mark Dickinson466e9262010-04-16 16:32:49 +0000607 @unittest.skipIf(USING_LINUXTHREADS,
608 "avoid triggering a linuxthreads bug: see issue #4970")
Guido van Rossume7ba4952007-06-06 23:52:48 +0000609 def test_execvpe_with_bad_program(self):
Mark Dickinson466e9262010-04-16 16:32:49 +0000610 self.assertRaises(OSError, os.execvpe, 'no such app-',
611 ['no such app-'], None)
Guido van Rossume7ba4952007-06-06 23:52:48 +0000612
Thomas Heller6790d602007-08-30 17:15:14 +0000613 def test_execvpe_with_bad_arglist(self):
614 self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
615
Antoine Pitrou1b643312010-01-17 12:19:45 +0000616class ArgTests(unittest.TestCase):
617 def test_bytearray(self):
618 # Issue #7561: posix module didn't release bytearray exports properly.
619 b = bytearray(os.sep.encode('ascii'))
620 self.assertRaises(OSError, os.mkdir, b)
621 # Check object is still resizable.
622 b[:] = b''
623
Thomas Wouters477c8d52006-05-27 19:21:47 +0000624class Win32ErrorTests(unittest.TestCase):
625 def test_rename(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000626 self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak")
Thomas Wouters477c8d52006-05-27 19:21:47 +0000627
628 def test_remove(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000629 self.assertRaises(WindowsError, os.remove, support.TESTFN)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000630
631 def test_chdir(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000632 self.assertRaises(WindowsError, os.chdir, support.TESTFN)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000633
634 def test_mkdir(self):
Amaury Forgeot d'Arc2fc224f2009-02-19 23:23:47 +0000635 f = open(support.TESTFN, "w")
Benjamin Petersonf91df042009-02-13 02:50:59 +0000636 try:
637 self.assertRaises(WindowsError, os.mkdir, support.TESTFN)
638 finally:
639 f.close()
Amaury Forgeot d'Arc2fc224f2009-02-19 23:23:47 +0000640 os.unlink(support.TESTFN)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000641
642 def test_utime(self):
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000643 self.assertRaises(WindowsError, os.utime, support.TESTFN, None)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000644
Thomas Wouters477c8d52006-05-27 19:21:47 +0000645 def test_chmod(self):
Benjamin Petersonf91df042009-02-13 02:50:59 +0000646 self.assertRaises(WindowsError, os.chmod, support.TESTFN, 0)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000647
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000648class TestInvalidFD(unittest.TestCase):
Benjamin Peterson05e782f2009-01-19 15:15:02 +0000649 singles = ["fchdir", "dup", "fdopen", "fdatasync", "fstat",
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000650 "fstatvfs", "fsync", "tcgetpgrp", "ttyname"]
651 #singles.append("close")
652 #We omit close because it doesn'r raise an exception on some platforms
653 def get_single(f):
654 def helper(self):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000655 if hasattr(os, f):
656 self.check(getattr(os, f))
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000657 return helper
658 for f in singles:
659 locals()["test_"+f] = get_single(f)
660
Benjamin Peterson7522c742009-01-19 21:00:09 +0000661 def check(self, f, *args):
Benjamin Peterson5c6d7872009-02-06 02:40:07 +0000662 try:
663 f(support.make_bad_fd(), *args)
664 except OSError as e:
665 self.assertEqual(e.errno, errno.EBADF)
666 else:
667 self.fail("%r didn't raise a OSError with a bad file descriptor"
668 % f)
Benjamin Peterson7522c742009-01-19 21:00:09 +0000669
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000670 def test_isatty(self):
671 if hasattr(os, "isatty"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000672 self.assertEqual(os.isatty(support.make_bad_fd()), False)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000673
674 def test_closerange(self):
675 if hasattr(os, "closerange"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000676 fd = support.make_bad_fd()
R. David Murray1f1b9a42009-07-22 15:23:36 +0000677 # Make sure none of the descriptors we are about to close are
678 # currently valid (issue 6542).
679 for i in range(10):
680 try: os.fstat(fd+i)
681 except OSError:
682 pass
683 else:
684 break
685 if i < 2:
686 raise unittest.SkipTest(
687 "Unable to acquire a range of invalid file descriptors")
688 self.assertEqual(os.closerange(fd, fd + i-1), None)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000689
690 def test_dup2(self):
691 if hasattr(os, "dup2"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000692 self.check(os.dup2, 20)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000693
694 def test_fchmod(self):
695 if hasattr(os, "fchmod"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000696 self.check(os.fchmod, 0)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000697
698 def test_fchown(self):
699 if hasattr(os, "fchown"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000700 self.check(os.fchown, -1, -1)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000701
702 def test_fpathconf(self):
703 if hasattr(os, "fpathconf"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000704 self.check(os.fpathconf, "PC_NAME_MAX")
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000705
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000706 def test_ftruncate(self):
707 if hasattr(os, "ftruncate"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000708 self.check(os.ftruncate, 0)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000709
710 def test_lseek(self):
711 if hasattr(os, "lseek"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000712 self.check(os.lseek, 0, 0)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000713
714 def test_read(self):
715 if hasattr(os, "read"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000716 self.check(os.read, 1)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000717
718 def test_tcsetpgrpt(self):
719 if hasattr(os, "tcsetpgrp"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000720 self.check(os.tcsetpgrp, 0)
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000721
722 def test_write(self):
723 if hasattr(os, "write"):
Benjamin Peterson7522c742009-01-19 21:00:09 +0000724 self.check(os.write, b" ")
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000725
Thomas Wouters477c8d52006-05-27 19:21:47 +0000726if sys.platform != 'win32':
727 class Win32ErrorTests(unittest.TestCase):
728 pass
729
Benjamin Petersonef3e4c22009-04-11 19:48:14 +0000730 class PosixUidGidTests(unittest.TestCase):
731 if hasattr(os, 'setuid'):
732 def test_setuid(self):
733 if os.getuid() != 0:
734 self.assertRaises(os.error, os.setuid, 0)
735 self.assertRaises(OverflowError, os.setuid, 1<<32)
736
737 if hasattr(os, 'setgid'):
738 def test_setgid(self):
739 if os.getuid() != 0:
740 self.assertRaises(os.error, os.setgid, 0)
741 self.assertRaises(OverflowError, os.setgid, 1<<32)
742
743 if hasattr(os, 'seteuid'):
744 def test_seteuid(self):
745 if os.getuid() != 0:
746 self.assertRaises(os.error, os.seteuid, 0)
747 self.assertRaises(OverflowError, os.seteuid, 1<<32)
748
749 if hasattr(os, 'setegid'):
750 def test_setegid(self):
751 if os.getuid() != 0:
752 self.assertRaises(os.error, os.setegid, 0)
753 self.assertRaises(OverflowError, os.setegid, 1<<32)
754
755 if hasattr(os, 'setreuid'):
756 def test_setreuid(self):
757 if os.getuid() != 0:
758 self.assertRaises(os.error, os.setreuid, 0, 0)
759 self.assertRaises(OverflowError, os.setreuid, 1<<32, 0)
760 self.assertRaises(OverflowError, os.setreuid, 0, 1<<32)
Benjamin Petersonc48b0552010-03-06 20:37:32 +0000761
762 def test_setreuid_neg1(self):
763 # Needs to accept -1. We run this in a subprocess to avoid
764 # altering the test runner's process state (issue8045).
765 import subprocess
766 subprocess.check_call([
767 sys.executable, '-c',
768 'import os,sys;os.setreuid(-1,-1);sys.exit(0)'])
Benjamin Petersonef3e4c22009-04-11 19:48:14 +0000769
770 if hasattr(os, 'setregid'):
771 def test_setregid(self):
772 if os.getuid() != 0:
773 self.assertRaises(os.error, os.setregid, 0, 0)
774 self.assertRaises(OverflowError, os.setregid, 1<<32, 0)
775 self.assertRaises(OverflowError, os.setregid, 0, 1<<32)
Benjamin Petersonc48b0552010-03-06 20:37:32 +0000776
777 def test_setregid_neg1(self):
778 # Needs to accept -1. We run this in a subprocess to avoid
779 # altering the test runner's process state (issue8045).
780 import subprocess
781 subprocess.check_call([
782 sys.executable, '-c',
783 'import os,sys;os.setregid(-1,-1);sys.exit(0)'])
Martin v. Löwis011e8422009-05-05 04:43:17 +0000784
Mark Dickinson70613682009-05-05 21:34:59 +0000785 @unittest.skipIf(sys.platform == 'darwin', "tests don't apply to OS X")
Martin v. Löwis011e8422009-05-05 04:43:17 +0000786 class Pep383Tests(unittest.TestCase):
787 filenames = [b'foo\xf6bar', 'foo\xf6bar'.encode("utf-8")]
788
789 def setUp(self):
790 self.fsencoding = sys.getfilesystemencoding()
791 sys.setfilesystemencoding("utf-8")
792 self.dir = support.TESTFN
Martin v. Löwis43c57782009-05-10 08:15:24 +0000793 self.bdir = self.dir.encode("utf-8", "surrogateescape")
Martin v. Löwis011e8422009-05-05 04:43:17 +0000794 os.mkdir(self.dir)
795 self.unicodefn = []
796 for fn in self.filenames:
797 f = open(os.path.join(self.bdir, fn), "w")
798 f.close()
Martin v. Löwis43c57782009-05-10 08:15:24 +0000799 self.unicodefn.append(fn.decode("utf-8", "surrogateescape"))
Martin v. Löwis011e8422009-05-05 04:43:17 +0000800
801 def tearDown(self):
802 shutil.rmtree(self.dir)
803 sys.setfilesystemencoding(self.fsencoding)
804
805 def test_listdir(self):
806 expected = set(self.unicodefn)
807 found = set(os.listdir(support.TESTFN))
Ezio Melotti19f2aeb2010-11-21 01:30:29 +0000808 self.assertEqual(found, expected)
Martin v. Löwis011e8422009-05-05 04:43:17 +0000809
810 def test_open(self):
811 for fn in self.unicodefn:
812 f = open(os.path.join(self.dir, fn))
813 f.close()
814
815 def test_stat(self):
816 for fn in self.unicodefn:
817 os.stat(os.path.join(self.dir, fn))
Benjamin Petersonef3e4c22009-04-11 19:48:14 +0000818else:
819 class PosixUidGidTests(unittest.TestCase):
820 pass
Martin v. Löwis011e8422009-05-05 04:43:17 +0000821 class Pep383Tests(unittest.TestCase):
822 pass
Benjamin Petersonef3e4c22009-04-11 19:48:14 +0000823
Fred Drake2e2be372001-09-20 21:33:42 +0000824def test_main():
Benjamin Petersonee8712c2008-05-20 21:35:26 +0000825 support.run_unittest(
Antoine Pitrou1b643312010-01-17 12:19:45 +0000826 ArgTests,
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000827 FileTests,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000828 StatAttributeTests,
829 EnvironTests,
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000830 WalkTests,
831 MakedirTests,
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000832 DevNullTests,
Thomas Wouters477c8d52006-05-27 19:21:47 +0000833 URandomTests,
Guido van Rossume7ba4952007-06-06 23:52:48 +0000834 ExecTests,
Benjamin Petersone1cdfd72009-01-18 21:02:37 +0000835 Win32ErrorTests,
Benjamin Petersonef3e4c22009-04-11 19:48:14 +0000836 TestInvalidFD,
Martin v. Löwis011e8422009-05-05 04:43:17 +0000837 PosixUidGidTests,
838 Pep383Tests
Walter Dörwald21d3a322003-05-01 17:45:56 +0000839 )
Fred Drake2e2be372001-09-20 21:33:42 +0000840
841if __name__ == "__main__":
842 test_main()