Skip to content

Commit b85780b

Browse files
author
Theofilos Manitaras
committed
Fix random 'test_sigterm' unittest failure
1 parent 3eb866b commit b85780b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

unittests/test_policies.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ def _runall(checks, conn):
270270
except BaseException as e:
271271
exc = e
272272

273-
conn.send((exc, len(self.runner.stats.failures())))
273+
stats = self.runner.stats
274+
conn.send((exc, stats.num_cases(), len(stats.failures())))
274275
conn.close()
275276

276277
rd_endpoint, wr_endpoint = multiprocessing.Pipe(duplex=False)
@@ -286,8 +287,11 @@ def _runall(checks, conn):
286287
time.sleep(1)
287288
p.terminate()
288289
p.join()
289-
exc, num_failures = rd_endpoint.recv()
290-
assert 1 == num_failures
290+
exc, num_cases, num_failures = rd_endpoint.recv()
291+
292+
# Either the test is submitted and it fails due to the termination
293+
# or it is not yet submitted when the termination signal is sent
294+
assert (num_cases, num_failures) in {(1, 1), (0, 0)}
291295
with pytest.raises(ReframeForceExitError,
292296
match='received TERM signal'):
293297
if exc:

0 commit comments

Comments
 (0)