From 80831754b3c1b9503d17d915db11a3dc0c077928 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 19 Feb 2020 12:43:23 +0200 Subject: [PATCH] Fail in TestProcessProto.setUp if bitmessage process dies --- src/tests/test_process.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tests/test_process.py b/src/tests/test_process.py index 73a6e493..a347f456 100644 --- a/src/tests/test_process.py +++ b/src/tests/test_process.py @@ -32,13 +32,22 @@ class TestProcessProto(unittest.TestCase): @classmethod def setUpClass(cls): """Setup environment and start pybitmessage""" + cls.flag = False cls.home = os.environ['BITMESSAGE_HOME'] = tempfile.gettempdir() put_signal_file(cls.home, 'unittest.lock') subprocess.call(cls._process_cmd) # nosec time.sleep(5) - cls.pid = int(cls._get_readline('singleton.lock')) + try: + cls.pid = int(cls._get_readline('singleton.lock')) + except TypeError: + cls.flag = True + return cls.process = psutil.Process(cls.pid) + def setUp(self): + if self.flag: + self.fail("%s is not started ):" % self._process_cmd) + @classmethod def _get_readline(cls, pfile): pfile = os.path.join(cls.home, pfile) @@ -71,7 +80,7 @@ class TestProcessProto(unittest.TestCase): if not cls._stop_process(): print(open(os.path.join(cls.home, 'debug.log'), 'rb').read()) cls.process.kill() - except psutil.NoSuchProcess: + except (psutil.NoSuchProcess, AttributeError): pass finally: cls._cleanup_files()