aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_tcp.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-25 11:23:04 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-25 11:23:04 +1200
commitf3237503a77258d37b67c5716ac178cbfd7ffe1b (patch)
tree3921db85a1abfb52442dcfa21c4bab8dd360bb05 /test/test_tcp.py
parent8f0754b9c48176aa479dc7701c42b26e115163a5 (diff)
downloadmitmproxy-f3237503a77258d37b67c5716ac178cbfd7ffe1b.tar.gz
mitmproxy-f3237503a77258d37b67c5716ac178cbfd7ffe1b.tar.bz2
mitmproxy-f3237503a77258d37b67c5716ac178cbfd7ffe1b.zip
Don't connect during __init__ methods for either client or server.
This means we now need to do these things explicitly at the caller.
Diffstat (limited to 'test/test_tcp.py')
-rw-r--r--test/test_tcp.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/test_tcp.py b/test/test_tcp.py
index 9aebb2f0..1bad9a04 100644
--- a/test/test_tcp.py
+++ b/test/test_tcp.py
@@ -46,7 +46,9 @@ class TServer(tcp.TCPServer):
self.ssl, self.q = ssl, q
def handle_connection(self, request, client_address):
- THandler(request, client_address, self)
+ h = THandler(request, client_address, self)
+ h.handle()
+ h.finish()
def handle_error(self, request, client_address):
s = cStringIO.StringIO()
@@ -64,7 +66,8 @@ class TestServer(ServerTestBase):
def test_echo(self):
testval = "echo!\n"
- c = tcp.TCPClient(False, "127.0.0.1", self.port, None, None)
+ c = tcp.TCPClient(False, "127.0.0.1", self.port, None)
+ c.connect()
c.wfile.write(testval)
c.wfile.flush()
assert c.rfile.readline() == testval
@@ -79,7 +82,8 @@ class TestServerSSL(ServerTestBase):
return s
def test_echo(self):
- c = tcp.TCPClient(True, "127.0.0.1", self.port, None, None)
+ c = tcp.TCPClient(True, "127.0.0.1", self.port, None)
+ c.connect()
testval = "echo!\n"
c.wfile.write(testval)
c.wfile.flush()
@@ -88,7 +92,8 @@ class TestServerSSL(ServerTestBase):
class TestTCPClient:
def test_conerr(self):
- tutils.raises(tcp.NetLibError, tcp.TCPClient, False, "127.0.0.1", 0, None, None)
+ c = tcp.TCPClient(True, "127.0.0.1", 0, None)
+ tutils.raises(tcp.NetLibError, c.connect)
class TestFileLike: