From 698123afec87514c51f81fd7de6eac0446e008b2 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 4 Nov 2020 17:35:17 +0200 Subject: [PATCH] Make TestAPIShutdown much like TestProcessShutdown (this version should pass on Fedora) --- src/tests/test_api.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tests/test_api.py b/src/tests/test_api.py index 1d8891a8..8cc63290 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -9,12 +9,14 @@ from .common import skip_python3 skip_python3() +import psutil + try: # nosec from xmlrpclib import ServerProxy, ProtocolError except ImportError: from xmlrpc.client import ServerProxy, ProtocolError -from .test_process import TestProcessProto, TestProcessShutdown +from .test_process import TestProcessProto class TestAPIProto(TestProcessProto): @@ -34,18 +36,16 @@ class TestAPIProto(TestProcessProto): time.sleep(1) -class TestAPIShutdown(TestAPIProto, TestProcessShutdown): +class TestAPIShutdown(TestAPIProto): """Separate test case for API command 'shutdown'""" def test_shutdown(self): """Shutdown the pybitmessage""" self.assertEqual(self.api.shutdown(), 'done') - for _ in range(5): - if not self.process.is_running(): - break - time.sleep(2) - else: + try: + self.process.wait(20) + except psutil.TimeoutExpired: self.fail( - '%s has not stopped in 10 sec' % ' '.join(self._process_cmd)) + '%s has not stopped in 20 sec' % ' '.join(self._process_cmd)) # TODO: uncovered API commands