From b85780be1b9a4a6fa94d704fe80f51f263ab4c93 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 4 Mar 2020 17:14:08 +0100 Subject: [PATCH] Fix random 'test_sigterm' unittest failure --- unittests/test_policies.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unittests/test_policies.py b/unittests/test_policies.py index 1ec7e8ebcf..77fbfe7e0a 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -270,7 +270,8 @@ def _runall(checks, conn): except BaseException as e: exc = e - conn.send((exc, len(self.runner.stats.failures()))) + stats = self.runner.stats + conn.send((exc, stats.num_cases(), len(stats.failures()))) conn.close() rd_endpoint, wr_endpoint = multiprocessing.Pipe(duplex=False) @@ -286,8 +287,11 @@ def _runall(checks, conn): time.sleep(1) p.terminate() p.join() - exc, num_failures = rd_endpoint.recv() - assert 1 == num_failures + exc, num_cases, num_failures = rd_endpoint.recv() + + # Either the test is submitted and it fails due to the termination + # or it is not yet submitted when the termination signal is sent + assert (num_cases, num_failures) in {(1, 1), (0, 0)} with pytest.raises(ReframeForceExitError, match='received TERM signal'): if exc: