aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlib/tcp.py2
-rw-r--r--test/test_tcp.py23
2 files changed, 12 insertions, 13 deletions
diff --git a/netlib/tcp.py b/netlib/tcp.py
index 45c60fd8..20e7d45f 100644
--- a/netlib/tcp.py
+++ b/netlib/tcp.py
@@ -302,7 +302,7 @@ class _Connection(object):
self.connection.shutdown()
except SSL.Error:
pass
- except KeyError as e:
+ except KeyError as e: # pragma: no cover
# Workaround for https://github.com/pyca/pyopenssl/pull/183
if OpenSSL.__version__ != "0.14":
raise e
diff --git a/test/test_tcp.py b/test/test_tcp.py
index b93b1e0a..4dbdd780 100644
--- a/test/test_tcp.py
+++ b/test/test_tcp.py
@@ -1,6 +1,7 @@
import cStringIO, Queue, time, socket, random
import os
from netlib import tcp, certutils, test, certffi
+import threading
import mock
import tutils
from OpenSSL import SSL
@@ -39,6 +40,15 @@ class TestServer(test.ServerTestBase):
c.wfile.flush()
assert c.rfile.readline() == testval
+ def test_thread_start_error(self):
+ with mock.patch.object(threading.Thread, "start", side_effect=threading.ThreadError("nonewthread")) as m:
+ c = tcp.TCPClient(("127.0.0.1", self.port))
+ c.connect()
+ assert not c.rfile.read(1)
+ assert m.called
+ assert "nonewthread" in self.q.get_nowait()
+ self.test_echo()
+
class TestServerBind(test.ServerTestBase):
class handler(tcp.BaseHandler):
@@ -72,7 +82,7 @@ class TestServerIPv6(test.ServerTestBase):
assert c.rfile.readline() == testval
-class TestDisconnect(test.ServerTestBase):
+class TestEcho(test.ServerTestBase):
handler = EchoHandler
def test_echo(self):
testval = "echo!\n"
@@ -553,17 +563,6 @@ class TestAddress:
assert repr(a)
-class TestServer(test.ServerTestBase):
- handler = EchoHandler
- def test_echo(self):
- testval = "echo!\n"
- c = tcp.TCPClient(("127.0.0.1", self.port))
- c.connect()
- c.wfile.write(testval)
- c.wfile.flush()
- assert c.rfile.readline() == testval
-
-
class TestSSLKeyLogger(test.ServerTestBase):
handler = EchoHandler
ssl = dict(