From 9c38093aa777126e224a0f67724bf94c04fe2f7c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 14 Mar 2019 19:31:39 +0000 Subject: [PATCH] issue #482: tests: check for zombie process after test. --- tests/testlib.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/testlib.py b/tests/testlib.py index 4cfd1b1c..7328ce09 100644 --- a/tests/testlib.py +++ b/tests/testlib.py @@ -341,7 +341,20 @@ class TestCase(unittest2.TestCase): self, self._fd_count_before, get_fd_count(), ) + def _teardown_check_zombies(self): + try: + pid, status, ru = os.wait3(os.WNOHANG) + except OSError: + return # ECHILD + + if pid: + assert 0, "%s failed to reap subprocess %d (status %d)." % ( + self, pid, status + ) + assert 0, "%s leaked still-running subprocesses." % (self,) + def tearDown(self): + self._teardown_check_zombies() self._teardown_check_threads() self._teardown_check_fds() super(TestCase, self).tearDown()