source: vendor/python/2.5/Lib/test/test_wait3.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 1.0 KB
RevLine 
[3225]1"""This test checks for correct wait3() behavior.
2"""
3
4import os
5import time
6from test.fork_wait import ForkWait
7from test.test_support import TestSkipped, run_unittest, reap_children
8
9try:
10 os.fork
11except AttributeError:
12 raise TestSkipped, "os.fork not defined -- skipping test_wait3"
13
14try:
15 os.wait3
16except AttributeError:
17 raise TestSkipped, "os.wait3 not defined -- skipping test_wait3"
18
19class Wait3Test(ForkWait):
20 def wait_impl(self, cpid):
21 for i in range(10):
22 # wait3() shouldn't hang, but some of the buildbots seem to hang
23 # in the forking tests. This is an attempt to fix the problem.
24 spid, status, rusage = os.wait3(os.WNOHANG)
25 if spid == cpid:
26 break
27 time.sleep(1.0)
28
29 self.assertEqual(spid, cpid)
30 self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
31 self.assertTrue(rusage)
32
33def test_main():
34 run_unittest(Wait3Test)
35 reap_children()
36
37if __name__ == "__main__":
38 test_main()
Note: See TracBrowser for help on using the repository browser.