Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Lib/test/fork_wait.py

Issue 3232042: #9424: convert deprecated assert methods in the Python test suite Base URL: http://svn.python.org/projects/python/branches/py3k/
Patch Set: Minor cleanups Created 14 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/buffer_tests.py ('k') | Lib/test/list_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """This test case provides support for checking forking and wait behavior. 1 """This test case provides support for checking forking and wait behavior.
2 2
3 To test different wait behavior, override the wait_impl method. 3 To test different wait behavior, override the wait_impl method.
4 4
5 We want fork1() semantics -- only the forking thread survives in the 5 We want fork1() semantics -- only the forking thread survives in the
6 child after a fork(). 6 child after a fork().
7 7
8 On some systems (e.g. Solaris without posix threads) we find that all 8 On some systems (e.g. Solaris without posix threads) we find that all
9 active threads survive in the child after a fork(); this is an error. 9 active threads survive in the child after a fork(); this is an error.
10 """ 10 """
(...skipping 22 matching lines...) Expand all
33 33
34 def wait_impl(self, cpid): 34 def wait_impl(self, cpid):
35 for i in range(10): 35 for i in range(10):
36 # waitpid() shouldn't hang, but some of the buildbots seem to hang 36 # waitpid() shouldn't hang, but some of the buildbots seem to hang
37 # in the forking tests. This is an attempt to fix the problem. 37 # in the forking tests. This is an attempt to fix the problem.
38 spid, status = os.waitpid(cpid, os.WNOHANG) 38 spid, status = os.waitpid(cpid, os.WNOHANG)
39 if spid == cpid: 39 if spid == cpid:
40 break 40 break
41 time.sleep(2 * SHORTSLEEP) 41 time.sleep(2 * SHORTSLEEP)
42 42
43 self.assertEquals(spid, cpid) 43 self.assertEqual(spid, cpid)
44 self.assertEquals(status, 0, "cause = %d, exit = %d" % (status&0xff, sta tus>>8)) 44 self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, stat us>>8))
45 45
46 def test_wait(self): 46 def test_wait(self):
47 for i in range(NUM_THREADS): 47 for i in range(NUM_THREADS):
48 _thread.start_new(self.f, (i,)) 48 _thread.start_new(self.f, (i,))
49 49
50 time.sleep(LONGSLEEP) 50 time.sleep(LONGSLEEP)
51 51
52 a = sorted(self.alive.keys()) 52 a = sorted(self.alive.keys())
53 self.assertEquals(a, list(range(NUM_THREADS))) 53 self.assertEqual(a, list(range(NUM_THREADS)))
54 54
55 prefork_lives = self.alive.copy() 55 prefork_lives = self.alive.copy()
56 56
57 if sys.platform in ['unixware7']: 57 if sys.platform in ['unixware7']:
58 cpid = os.fork1() 58 cpid = os.fork1()
59 else: 59 else:
60 cpid = os.fork() 60 cpid = os.fork()
61 61
62 if cpid == 0: 62 if cpid == 0:
63 # Child 63 # Child
64 time.sleep(LONGSLEEP) 64 time.sleep(LONGSLEEP)
65 n = 0 65 n = 0
66 for key in self.alive: 66 for key in self.alive:
67 if self.alive[key] != prefork_lives[key]: 67 if self.alive[key] != prefork_lives[key]:
68 n += 1 68 n += 1
69 os._exit(n) 69 os._exit(n)
70 else: 70 else:
71 # Parent 71 # Parent
72 self.wait_impl(cpid) 72 self.wait_impl(cpid)
73 # Tell threads to die 73 # Tell threads to die
74 self.stop = 1 74 self.stop = 1
75 time.sleep(2*SHORTSLEEP) # Wait for threads to die 75 time.sleep(2*SHORTSLEEP) # Wait for threads to die
OLDNEW
« no previous file with comments | « Lib/test/buffer_tests.py ('k') | Lib/test/list_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b