]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Relax test failure when failing to reproduce the race condition
authorAntoine Pitrou <antoine@python.org>
Tue, 6 Jun 2017 09:03:22 +0000 (11:03 +0200)
committerAntoine Pitrou <antoine@python.org>
Tue, 6 Jun 2017 09:03:22 +0000 (11:03 +0200)
tornado/test/tcpserver_test.py

index 46841b32ef43abfa8ee73532ae82631220859c55..2417992cde306f5bf5117f79b673f40861806a17 100644 (file)
@@ -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