aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_tcp.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-04-12 11:32:27 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-04-12 11:32:27 +1200
commit1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7 (patch)
tree6fa02d74fc2c43c2ad8c43ba5d669c54c43d2dc8 /test/test_tcp.py
parent2630da7263242411d413b5e4b2c520d29848c918 (diff)
parente58f76aec1db9cc784a3b73c3050d010bb084968 (diff)
downloadmitmproxy-1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7.tar.gz
mitmproxy-1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7.tar.bz2
mitmproxy-1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7.zip
Merge branch 'master' of https://github.com/mitmproxy/netlib
Diffstat (limited to 'test/test_tcp.py')
-rw-r--r--test/test_tcp.py23
1 files changed, 11 insertions, 12 deletions
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(