diff options
-rw-r--r-- | Lib/test/test_random.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index f657b46..fbb1cf6 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -907,7 +907,9 @@ class TestModule(unittest.TestCase): def test_after_fork(self): # Test the global Random instance gets reseeded in child r, w = os.pipe() - if os.fork() == 0: + pid = os.fork() + if pid == 0: + # child process try: val = random.getrandbits(128) with open(w, "w") as f: @@ -915,12 +917,16 @@ class TestModule(unittest.TestCase): finally: os._exit(0) else: + # parent process os.close(w) val = random.getrandbits(128) with open(r, "r") as f: child_val = eval(f.read()) self.assertNotEqual(val, child_val) + pid, status = os.waitpid(pid, 0) + self.assertEqual(status, 0) + if __name__ == "__main__": unittest.main() |