summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-07-19 12:46:46 (GMT)
committerGuido van Rossum <guido@python.org>2002-07-19 12:46:46 (GMT)
commitb6cc7d2806d0e7784abf8479bfed3543de48bb97 (patch)
treec0644c149f5af38331f73b26879915848af2959d /Lib/test/test_socket.py
parentad654906288a1ed985b8649c75a9c6037448cb9d (diff)
downloadcpython-b6cc7d2806d0e7784abf8479bfed3543de48bb97.zip
cpython-b6cc7d2806d0e7784abf8479bfed3543de48bb97.tar.gz
cpython-b6cc7d2806d0e7784abf8479bfed3543de48bb97.tar.bz2
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!)
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index b9b9db6..d358966 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -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):