bpo-40094: Enhance fork and wait tests (GH-19259)

* test_fork1: remove duplicated wait_impl() method: reuse
  fork_wait.py implementation instead.
* Use exit code different than 0 to ensure that we executed the
  expected code path.
This commit is contained in:
Victor Stinner 2020-03-31 21:46:40 +02:00 committed by GitHub
parent 278c1e159c
commit 27c6231f58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 24 deletions

View file

@ -16,7 +16,7 @@ if not hasattr(os, 'wait3'):
raise unittest.SkipTest("os.wait3 not defined")
class Wait3Test(ForkWait):
def wait_impl(self, cpid):
def wait_impl(self, cpid, *, exitcode):
# This many iterations can be required, since some previously run
# tests (e.g. test_ctypes) could have spawned a lot of children
# very quickly.
@ -30,7 +30,8 @@ class Wait3Test(ForkWait):
time.sleep(0.1)
self.assertEqual(spid, cpid)
self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
self.assertEqual(status, exitcode << 8,
"cause = %d, exit = %d" % (status&0xff, status>>8))
self.assertTrue(rusage)
def test_wait3_rusage_initialized(self):