From: Antoine Pitrou Date: Tue, 6 Jun 2017 09:03:22 +0000 (+0200) Subject: Relax test failure when failing to reproduce the race condition X-Git-Tag: v5.0.0~67^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7d8ad2dd68b1f0b623c2ab3dc4043635e78b184;p=thirdparty%2Ftornado.git Relax test failure when failing to reproduce the race condition --- diff --git a/tornado/test/tcpserver_test.py b/tornado/test/tcpserver_test.py index 46841b32e..2417992cd 100644 --- a/tornado/test/tcpserver_test.py +++ b/tornado/test/tcpserver_test.py @@ -1,10 +1,9 @@ from __future__ import absolute_import, division, print_function -#from functools import partial import socket from tornado import gen -from tornado.iostream import IOStream, StreamClosedError +from tornado.iostream import IOStream from tornado.log import app_log from tornado.stack_context import NullContext from tornado.tcpserver import TCPServer @@ -103,11 +102,14 @@ class TCPServerTest(AsyncTestCase): self.assertGreater(len(connected_clients), 0, "all clients failed connecting") - self.assertLess(len(connected_clients), N, - "at least one client should fail connecting for " - "the test to be meaningful") - - for c in connected_clients: - c.close() - # AsyncTestCase.tearDown() would re-raise the EBADF encountered in the IO loop + try: + if len(connected_clients) == N: + # Ideally we'd make the test deterministic, but we're testing + # for a race condition in combination with the system's TCP stack... + self.skipTest("at least one client should fail connecting " + "for the test to be meaningful") + finally: + for c in connected_clients: + c.close() + # Here tearDown() would re-raise the EBADF encountered in the IO loop