blob: a4417b016a2ec840c906f4eccf23d684d54b5bdc [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
6import unittest
Jeremy Hyltona7fc21b2001-08-20 20:10:01 +00007import warnings
Martin v. Löwis8e0d4942006-05-04 10:08:42 +00008import sys
Walter Dörwald21d3a322003-05-01 17:45:56 +00009from test import test_support
Fred Drake38c2ef02001-07-17 20:52:51 +000010
Barry Warsaw60f01882001-08-22 19:24:42 +000011warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
12warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
13
Martin v. Löwisee1e06d2006-07-02 18:44:00 +000014# Tests creating TESTFN
15class FileTests(unittest.TestCase):
16 def setUp(self):
17 if os.path.exists(test_support.TESTFN):
18 os.unlink(test_support.TESTFN)
19 tearDown = setUp
20
21 def test_access(self):
22 f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
23 os.close(f)
24 self.assert_(os.access(test_support.TESTFN, os.W_OK))
Tim Peters16a39322006-07-03 08:23:19 +000025
Martin v. Löwisee1e06d2006-07-02 18:44:00 +000026
Fred Drake38c2ef02001-07-17 20:52:51 +000027class TemporaryFileTests(unittest.TestCase):
28 def setUp(self):
29 self.files = []
Walter Dörwald21d3a322003-05-01 17:45:56 +000030 os.mkdir(test_support.TESTFN)
Fred Drake38c2ef02001-07-17 20:52:51 +000031
32 def tearDown(self):
33 for name in self.files:
34 os.unlink(name)
Walter Dörwald21d3a322003-05-01 17:45:56 +000035 os.rmdir(test_support.TESTFN)
Fred Drake38c2ef02001-07-17 20:52:51 +000036
37 def check_tempfile(self, name):
38 # make sure it doesn't already exist:
39 self.failIf(os.path.exists(name),
40 "file already exists for temporary file")
41 # make sure we can create the file
42 open(name, "w")
43 self.files.append(name)
44
45 def test_tempnam(self):
46 if not hasattr(os, "tempnam"):
47 return
Jeremy Hyltona7fc21b2001-08-20 20:10:01 +000048 warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
Tim Petersd3925062002-04-16 01:27:44 +000049 r"test_os$")
Fred Drake38c2ef02001-07-17 20:52:51 +000050 self.check_tempfile(os.tempnam())
51
Walter Dörwald21d3a322003-05-01 17:45:56 +000052 name = os.tempnam(test_support.TESTFN)
Fred Drake38c2ef02001-07-17 20:52:51 +000053 self.check_tempfile(name)
54
Walter Dörwald21d3a322003-05-01 17:45:56 +000055 name = os.tempnam(test_support.TESTFN, "pfx")
Fred Drake38c2ef02001-07-17 20:52:51 +000056 self.assert_(os.path.basename(name)[:3] == "pfx")
57 self.check_tempfile(name)
58
59 def test_tmpfile(self):
60 if not hasattr(os, "tmpfile"):
61 return
Martin v. Löwisbc898972008-03-06 06:57:02 +000062 # As with test_tmpnam() below, the Windows implementation of tmpfile()
63 # attempts to create a file in the root directory of the current drive.
64 # On Vista and Server 2008, this test will always fail for normal users
65 # as writing to the root directory requires elevated privileges. With
66 # XP and below, the semantics of tmpfile() are the same, but the user
67 # running the test is more likely to have administrative privileges on
68 # their account already. If that's the case, then os.tmpfile() should
69 # work. In order to make this test as useful as possible, rather than
70 # trying to detect Windows versions or whether or not the user has the
71 # right permissions, just try and create a file in the root directory
72 # and see if it raises a 'Permission denied' OSError. If it does, then
73 # test that a subsequent call to os.tmpfile() raises the same error. If
74 # it doesn't, assume we're on XP or below and the user running the test
75 # has administrative privileges, and proceed with the test as normal.
76 if sys.platform == 'win32':
77 name = '\\python_test_os_test_tmpfile.txt'
78 if os.path.exists(name):
79 os.remove(name)
80 try:
81 fp = open(name, 'w')
82 except IOError, first:
83 # open() failed, assert tmpfile() fails in the same way.
84 # Although open() raises an IOError and os.tmpfile() raises an
85 # OSError(), 'args' will be (13, 'Permission denied') in both
86 # cases.
87 try:
88 fp = os.tmpfile()
89 except OSError, second:
90 self.assertEqual(first.args, second.args)
91 else:
92 self.fail("expected os.tmpfile() to raise OSError")
93 return
94 else:
95 # open() worked, therefore, tmpfile() should work. Close our
96 # dummy file and proceed with the test as normal.
97 fp.close()
98 os.remove(name)
99
Fred Drake38c2ef02001-07-17 20:52:51 +0000100 fp = os.tmpfile()
101 fp.write("foobar")
102 fp.seek(0,0)
103 s = fp.read()
104 fp.close()
105 self.assert_(s == "foobar")
106
107 def test_tmpnam(self):
Tim Peters5501b5e2003-04-28 03:13:03 +0000108 import sys
Fred Drake38c2ef02001-07-17 20:52:51 +0000109 if not hasattr(os, "tmpnam"):
110 return
Jeremy Hyltona7fc21b2001-08-20 20:10:01 +0000111 warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
Tim Petersd3925062002-04-16 01:27:44 +0000112 r"test_os$")
Tim Peters5501b5e2003-04-28 03:13:03 +0000113 name = os.tmpnam()
114 if sys.platform in ("win32",):
115 # The Windows tmpnam() seems useless. From the MS docs:
116 #
117 # The character string that tmpnam creates consists of
118 # the path prefix, defined by the entry P_tmpdir in the
119 # file STDIO.H, followed by a sequence consisting of the
120 # digit characters '0' through '9'; the numerical value
121 # of this string is in the range 1 - 65,535. Changing the
122 # definitions of L_tmpnam or P_tmpdir in STDIO.H does not
123 # change the operation of tmpnam.
124 #
125 # The really bizarre part is that, at least under MSVC6,
126 # P_tmpdir is "\\". That is, the path returned refers to
127 # the root of the current drive. That's a terrible place to
128 # put temp files, and, depending on privileges, the user
129 # may not even be able to open a file in the root directory.
130 self.failIf(os.path.exists(name),
131 "file already exists for temporary file")
132 else:
133 self.check_tempfile(name)
Tim Peters87cc0c32001-07-21 01:41:30 +0000134
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000135# Test attributes on return values from os.*stat* family.
136class StatAttributeTests(unittest.TestCase):
137 def setUp(self):
Walter Dörwald21d3a322003-05-01 17:45:56 +0000138 os.mkdir(test_support.TESTFN)
139 self.fname = os.path.join(test_support.TESTFN, "f1")
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000140 f = open(self.fname, 'wb')
141 f.write("ABC")
142 f.close()
Tim Peterse0c446b2001-10-18 21:57:37 +0000143
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000144 def tearDown(self):
145 os.unlink(self.fname)
Walter Dörwald21d3a322003-05-01 17:45:56 +0000146 os.rmdir(test_support.TESTFN)
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000147
148 def test_stat_attributes(self):
149 if not hasattr(os, "stat"):
150 return
151
152 import stat
153 result = os.stat(self.fname)
154
155 # Make sure direct access works
156 self.assertEquals(result[stat.ST_SIZE], 3)
157 self.assertEquals(result.st_size, 3)
158
159 import sys
160
161 # Make sure all the attributes are there
162 members = dir(result)
163 for name in dir(stat):
164 if name[:3] == 'ST_':
165 attr = name.lower()
Martin v. Löwis4d394df2005-01-23 09:19:22 +0000166 if name.endswith("TIME"):
167 def trunc(x): return int(x)
168 else:
169 def trunc(x): return x
170 self.assertEquals(trunc(getattr(result, attr)),
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000171 result[getattr(stat, name)])
172 self.assert_(attr in members)
173
174 try:
175 result[200]
176 self.fail("No exception thrown")
177 except IndexError:
178 pass
179
180 # Make sure that assignment fails
181 try:
182 result.st_mode = 1
183 self.fail("No exception thrown")
184 except TypeError:
185 pass
186
187 try:
188 result.st_rdev = 1
189 self.fail("No exception thrown")
Guido van Rossum1fff8782001-10-18 21:19:31 +0000190 except (AttributeError, TypeError):
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000191 pass
192
193 try:
194 result.parrot = 1
195 self.fail("No exception thrown")
196 except AttributeError:
197 pass
198
199 # Use the stat_result constructor with a too-short tuple.
200 try:
201 result2 = os.stat_result((10,))
202 self.fail("No exception thrown")
203 except TypeError:
204 pass
205
206 # Use the constructr with a too-long tuple.
207 try:
208 result2 = os.stat_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14))
209 except TypeError:
210 pass
211
Tim Peterse0c446b2001-10-18 21:57:37 +0000212
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000213 def test_statvfs_attributes(self):
214 if not hasattr(os, "statvfs"):
215 return
216
217 import statvfs
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000218 try:
219 result = os.statvfs(self.fname)
220 except OSError, e:
221 # On AtheOS, glibc always returns ENOSYS
222 import errno
223 if e.errno == errno.ENOSYS:
224 return
Guido van Rossum98bf58f2001-10-18 20:34:25 +0000225
226 # Make sure direct access works
227 self.assertEquals(result.f_bfree, result[statvfs.F_BFREE])
228
229 # Make sure all the attributes are there
230 members = dir(result)
231 for name in dir(statvfs):
232 if name[:2] == 'F_':
233 attr = name.lower()
234 self.assertEquals(getattr(result, attr),
235 result[getattr(statvfs, name)])
236 self.assert_(attr in members)
237
238 # Make sure that assignment really fails
239 try:
240 result.f_bfree = 1
241 self.fail("No exception thrown")
242 except TypeError:
243 pass
244
245 try:
246 result.parrot = 1
247 self.fail("No exception thrown")
248 except AttributeError:
249 pass
250
251 # Use the constructor with a too-short tuple.
252 try:
253 result2 = os.statvfs_result((10,))
254 self.fail("No exception thrown")
255 except TypeError:
256 pass
257
258 # Use the constructr with a too-long tuple.
259 try:
260 result2 = os.statvfs_result((0,1,2,3,4,5,6,7,8,9,10,11,12,13,14))
261 except TypeError:
262 pass
Fred Drake38c2ef02001-07-17 20:52:51 +0000263
Martin v. Löwis463a42b2006-10-09 20:44:50 +0000264 # Restrict test to Win32, since there is no guarantee other
265 # systems support centiseconds
266 if sys.platform == 'win32':
Martin v. Löwis39f1f452007-08-30 18:58:29 +0000267 def get_file_system(path):
Hirokazu Yamamoto534c6e62008-08-20 04:20:53 +0000268 root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'
Martin v. Löwis39f1f452007-08-30 18:58:29 +0000269 import ctypes
Hirokazu Yamamoto534c6e62008-08-20 04:20:53 +0000270 from ctypes.wintypes import LPCWSTR, LPWSTR, DWORD
271 LPDWORD = ctypes.POINTER(DWORD)
272 f = ctypes.windll.kernel32.GetVolumeInformationW
273 f.argtypes = (LPCWSTR, LPWSTR, DWORD,
274 LPDWORD, LPDWORD, LPDWORD, LPWSTR, DWORD)
275 buf = ctypes.create_unicode_buffer("", 100)
276 if f(root, None, 0, None, None, None, buf, len(buf)):
Martin v. Löwis39f1f452007-08-30 18:58:29 +0000277 return buf.value
278
279 if get_file_system(test_support.TESTFN) == "NTFS":
280 def test_1565150(self):
281 t1 = 1159195039.25
282 os.utime(self.fname, (t1, t1))
283 self.assertEquals(os.stat(self.fname).st_mtime, t1)
Martin v. Löwis463a42b2006-10-09 20:44:50 +0000284
Martin v. Löwis88635442007-04-04 18:30:56 +0000285 def test_1686475(self):
286 # Verify that an open file can be stat'ed
287 try:
288 os.stat(r"c:\pagefile.sys")
289 except WindowsError, e:
290 if e == 2: # file does not exist; cannot run test
291 return
292 self.fail("Could not stat pagefile.sys")
293
Walter Dörwald0a6d0ff2004-05-31 16:29:04 +0000294from test import mapping_tests
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000295
Walter Dörwald0a6d0ff2004-05-31 16:29:04 +0000296class EnvironTests(mapping_tests.BasicTestMappingProtocol):
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000297 """check that os.environ object conform to mapping protocol"""
Walter Dörwald118f9312004-06-02 18:42:25 +0000298 type2test = None
Raymond Hettinger2c2d3222003-03-09 07:05:43 +0000299 def _reference(self):
300 return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
301 def _empty_mapping(self):
302 os.environ.clear()
303 return os.environ
304 def setUp(self):
305 self.__save = dict(os.environ)
306 os.environ.clear()
307 def tearDown(self):
308 os.environ.clear()
309 os.environ.update(self.__save)
310
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000311 # Bug 1110478
Martin v. Löwis5510f652005-02-17 21:23:20 +0000312 def test_update2(self):
Martin v. Löwis1d11de62005-01-29 13:29:23 +0000313 if os.path.exists("/bin/sh"):
314 os.environ.update(HELLO="World")
315 value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
316 self.assertEquals(value, "World")
317
Tim Petersc4e09402003-04-25 07:11:48 +0000318class WalkTests(unittest.TestCase):
319 """Tests for os.walk()."""
320
321 def test_traversal(self):
322 import os
323 from os.path import join
324
325 # Build:
326 # TESTFN/ a file kid and two directory kids
327 # tmp1
328 # SUB1/ a file kid and a directory kid
329 # tmp2
330 # SUB11/ no kids
331 # SUB2/ just a file kid
332 # tmp3
Walter Dörwald21d3a322003-05-01 17:45:56 +0000333 sub1_path = join(test_support.TESTFN, "SUB1")
Tim Petersc4e09402003-04-25 07:11:48 +0000334 sub11_path = join(sub1_path, "SUB11")
Walter Dörwald21d3a322003-05-01 17:45:56 +0000335 sub2_path = join(test_support.TESTFN, "SUB2")
336 tmp1_path = join(test_support.TESTFN, "tmp1")
Tim Petersc4e09402003-04-25 07:11:48 +0000337 tmp2_path = join(sub1_path, "tmp2")
338 tmp3_path = join(sub2_path, "tmp3")
339
340 # Create stuff.
341 os.makedirs(sub11_path)
342 os.makedirs(sub2_path)
343 for path in tmp1_path, tmp2_path, tmp3_path:
344 f = file(path, "w")
345 f.write("I'm " + path + " and proud of it. Blame test_os.\n")
346 f.close()
347
348 # Walk top-down.
Walter Dörwald21d3a322003-05-01 17:45:56 +0000349 all = list(os.walk(test_support.TESTFN))
Tim Petersc4e09402003-04-25 07:11:48 +0000350 self.assertEqual(len(all), 4)
351 # We can't know which order SUB1 and SUB2 will appear in.
352 # Not flipped: TESTFN, SUB1, SUB11, SUB2
353 # flipped: TESTFN, SUB2, SUB1, SUB11
354 flipped = all[0][1][0] != "SUB1"
355 all[0][1].sort()
Walter Dörwald21d3a322003-05-01 17:45:56 +0000356 self.assertEqual(all[0], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000357 self.assertEqual(all[1 + flipped], (sub1_path, ["SUB11"], ["tmp2"]))
358 self.assertEqual(all[2 + flipped], (sub11_path, [], []))
359 self.assertEqual(all[3 - 2 * flipped], (sub2_path, [], ["tmp3"]))
360
361 # Prune the search.
362 all = []
Walter Dörwald21d3a322003-05-01 17:45:56 +0000363 for root, dirs, files in os.walk(test_support.TESTFN):
Tim Petersc4e09402003-04-25 07:11:48 +0000364 all.append((root, dirs, files))
365 # Don't descend into SUB1.
366 if 'SUB1' in dirs:
367 # Note that this also mutates the dirs we appended to all!
368 dirs.remove('SUB1')
369 self.assertEqual(len(all), 2)
Walter Dörwald21d3a322003-05-01 17:45:56 +0000370 self.assertEqual(all[0], (test_support.TESTFN, ["SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000371 self.assertEqual(all[1], (sub2_path, [], ["tmp3"]))
372
373 # Walk bottom-up.
Walter Dörwald21d3a322003-05-01 17:45:56 +0000374 all = list(os.walk(test_support.TESTFN, topdown=False))
Tim Petersc4e09402003-04-25 07:11:48 +0000375 self.assertEqual(len(all), 4)
376 # We can't know which order SUB1 and SUB2 will appear in.
377 # Not flipped: SUB11, SUB1, SUB2, TESTFN
378 # flipped: SUB2, SUB11, SUB1, TESTFN
379 flipped = all[3][1][0] != "SUB1"
380 all[3][1].sort()
Walter Dörwald21d3a322003-05-01 17:45:56 +0000381 self.assertEqual(all[3], (test_support.TESTFN, ["SUB1", "SUB2"], ["tmp1"]))
Tim Petersc4e09402003-04-25 07:11:48 +0000382 self.assertEqual(all[flipped], (sub11_path, [], []))
383 self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"]))
384 self.assertEqual(all[2 - 2 * flipped], (sub2_path, [], ["tmp3"]))
385
386 # Tear everything down. This is a decent use for bottom-up on
387 # Windows, which doesn't have a recursive delete command. The
388 # (not so) subtlety is that rmdir will fail unless the dir's
389 # kids are removed first, so bottom up is essential.
Walter Dörwald21d3a322003-05-01 17:45:56 +0000390 for root, dirs, files in os.walk(test_support.TESTFN, topdown=False):
Tim Petersc4e09402003-04-25 07:11:48 +0000391 for name in files:
392 os.remove(join(root, name))
393 for name in dirs:
394 os.rmdir(join(root, name))
Walter Dörwald21d3a322003-05-01 17:45:56 +0000395 os.rmdir(test_support.TESTFN)
Tim Petersc4e09402003-04-25 07:11:48 +0000396
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000397class MakedirTests (unittest.TestCase):
398 def setUp(self):
399 os.mkdir(test_support.TESTFN)
400
401 def test_makedir(self):
402 base = test_support.TESTFN
403 path = os.path.join(base, 'dir1', 'dir2', 'dir3')
404 os.makedirs(path) # Should work
405 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
406 os.makedirs(path)
407
408 # Try paths with a '.' in them
409 self.failUnlessRaises(OSError, os.makedirs, os.curdir)
410 path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir)
411 os.makedirs(path)
412 path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4',
413 'dir5', 'dir6')
414 os.makedirs(path)
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000415
Tim Peters58eb11c2004-01-18 20:29:55 +0000416
417
418
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000419 def tearDown(self):
420 path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3',
421 'dir4', 'dir5', 'dir6')
422 # If the tests failed, the bottom-most directory ('../dir6')
423 # may not have been created, so we look for the outermost directory
424 # that exists.
425 while not os.path.exists(path) and path != test_support.TESTFN:
426 path = os.path.dirname(path)
427
428 os.removedirs(path)
429
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000430class DevNullTests (unittest.TestCase):
431 def test_devnull(self):
432 f = file(os.devnull, 'w')
433 f.write('hello')
434 f.close()
435 f = file(os.devnull, 'r')
Tim Peters4182cfd2004-06-08 20:34:34 +0000436 self.assertEqual(f.read(), '')
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000437 f.close()
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000438
Martin v. Löwisdc3883f2004-08-29 15:46:35 +0000439class URandomTests (unittest.TestCase):
440 def test_urandom(self):
441 try:
442 self.assertEqual(len(os.urandom(1)), 1)
443 self.assertEqual(len(os.urandom(10)), 10)
444 self.assertEqual(len(os.urandom(100)), 100)
445 self.assertEqual(len(os.urandom(1000)), 1000)
446 except NotImplementedError:
447 pass
448
Martin v. Löwis8e0d4942006-05-04 10:08:42 +0000449class Win32ErrorTests(unittest.TestCase):
450 def test_rename(self):
451 self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak")
452
453 def test_remove(self):
454 self.assertRaises(WindowsError, os.remove, test_support.TESTFN)
455
456 def test_chdir(self):
457 self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
458
Martin v. Löwisd4e3bb32006-05-06 16:32:54 +0000459 def test_mkdir(self):
460 self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
461
462 def test_utime(self):
463 self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None)
464
465 def test_access(self):
466 self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0)
467
468 def test_chmod(self):
469 self.assertRaises(WindowsError, os.utime, test_support.TESTFN, 0)
470
Martin v. Löwis8e0d4942006-05-04 10:08:42 +0000471if sys.platform != 'win32':
472 class Win32ErrorTests(unittest.TestCase):
473 pass
474
Fred Drake2e2be372001-09-20 21:33:42 +0000475def test_main():
Walter Dörwald21d3a322003-05-01 17:45:56 +0000476 test_support.run_unittest(
Martin v. Löwisee1e06d2006-07-02 18:44:00 +0000477 FileTests,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000478 TemporaryFileTests,
479 StatAttributeTests,
480 EnvironTests,
Andrew M. Kuchlingb386f6a2003-12-23 16:36:11 +0000481 WalkTests,
482 MakedirTests,
Martin v. Löwisbdec50f2004-06-08 08:29:33 +0000483 DevNullTests,
Martin v. Löwis8e0d4942006-05-04 10:08:42 +0000484 URandomTests,
485 Win32ErrorTests
Walter Dörwald21d3a322003-05-01 17:45:56 +0000486 )
Fred Drake2e2be372001-09-20 21:33:42 +0000487
488if __name__ == "__main__":
489 test_main()