mirror of https://github.com/python/cpython
Add test for previous core dump when sending on closed socket with
timeout. Added small sleeps to _testAccept() and _testRecv() in NonBlockingTCPTests, to reduce race conditions (I know, this is not the solution!)
This commit is contained in:
parent
ad65490628
commit
b6cc7d2806
|
@ -325,7 +325,7 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
# Check that setting it to an invalid type raises TypeError
|
||||
self.assertRaises(TypeError, socket.setdefaulttimeout, "spam")
|
||||
|
||||
# XXX The following three don't test module-level functionality...
|
||||
# XXX The following don't test module-level functionality...
|
||||
|
||||
def testSockName(self):
|
||||
"""Testing getsockname()."""
|
||||
|
@ -348,6 +348,13 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
|
||||
self.failIf(reuse == 0, "failed to set reuse mode")
|
||||
|
||||
def testSendAfterClose(self):
|
||||
"""testing send() after close() with timeout."""
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.settimeout(1)
|
||||
sock.close()
|
||||
self.assertRaises(socket.error, sock.send, "spam")
|
||||
|
||||
class BasicTCPTest(SocketConnectedTest):
|
||||
|
||||
def __init__(self, methodName='runTest'):
|
||||
|
@ -486,6 +493,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
|||
self.fail("Error trying to do accept after select.")
|
||||
|
||||
def _testAccept(self):
|
||||
time.sleep(0.1)
|
||||
self.cli.connect((HOST, PORT))
|
||||
|
||||
def testConnect(self):
|
||||
|
@ -515,6 +523,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
|
|||
|
||||
def _testRecv(self):
|
||||
self.cli.connect((HOST, PORT))
|
||||
time.sleep(0.1)
|
||||
self.cli.send(MSG)
|
||||
|
||||
class FileObjectClassTestCase(SocketConnectedTest):
|
||||
|
|
Loading…
Reference in New Issue