From 978d8cfa072d0f79ebe5f63a4b7de2d7e7cf5fe5 Mon Sep 17 00:00:00 2001 From: "jai.s" Date: Wed, 14 Oct 2020 14:14:23 +0530 Subject: [PATCH] Added psutil's wait process condition on the tearDownClass method --- src/tests/test_process.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tests/test_process.py b/src/tests/test_process.py index 0c18b75c..8fbc7e04 100755 --- a/src/tests/test_process.py +++ b/src/tests/test_process.py @@ -100,10 +100,17 @@ class TestProcessProto(unittest.TestCase): print('is ever called tearDownC') if not cls._stop_process(): cls.process.kill() - logger.error('***********************') - logger.error('tearDownClass are successfully killed') - logger.error('***********************') + gone, alive = psutil.wait_procs(cls.process, timeout = 3, + callback = None) + for p in alive: + p.kill() + print('***********************') + print('tearDownClass are successfully killed') + print('***********************') except (psutil.NoSuchProcess, FileNotFoundError, AttributeError) as e: + print('################################') + print('TearDownClass except section') + print('################################') pass finally: cls._cleanup_files()