mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
Test suite, remove extraneous code.
This commit is contained in:
parent
1e0bab65e3
commit
57f01ffb07
@ -96,11 +96,8 @@ class ServerConnection(tcp.TCPClient):
|
||||
d = request._assemble()
|
||||
if not d:
|
||||
raise ProxyError(502, "Cannot transmit an incomplete request.")
|
||||
try:
|
||||
self.wfile.write(d)
|
||||
self.wfile.flush()
|
||||
except socket.error, err:
|
||||
raise ProxyError(502, 'Error sending data to "%s": %s' % (request.host, err))
|
||||
self.wfile.write(d)
|
||||
self.wfile.flush()
|
||||
|
||||
def terminate(self):
|
||||
try:
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
git log | grep "^Author:" | sed 's/ <.*//; s/^Author: //' | sort | uniq -c | sort -nr
|
||||
git shortlog -n -s
|
||||
|
@ -2,6 +2,7 @@ from libmproxy import proxy, flow
|
||||
import tutils
|
||||
from libpathod import test
|
||||
from netlib import http
|
||||
import mock
|
||||
|
||||
|
||||
def test_proxy_error():
|
||||
@ -30,7 +31,6 @@ def test_app_registry():
|
||||
assert ar.get(r)
|
||||
|
||||
|
||||
|
||||
class TestServerConnection:
|
||||
def setUp(self):
|
||||
self.d = test.Daemon()
|
||||
@ -50,9 +50,11 @@ class TestServerConnection:
|
||||
r.content = flow.CONTENT_MISSING
|
||||
tutils.raises("incomplete request", sc.send, r)
|
||||
|
||||
def test_send_error(self):
|
||||
sc.terminate()
|
||||
|
||||
def test_terminate_error(self):
|
||||
sc = proxy.ServerConnection(proxy.ProxyConfig(), self.d.IFACE, self.d.port)
|
||||
sc.connect("http")
|
||||
r = tutils.treq()
|
||||
sc.send(r)
|
||||
|
||||
sc.connection = mock.Mock()
|
||||
sc.connection.close = mock.Mock(side_effect=IOError)
|
||||
sc.terminate()
|
||||
|
Loading…
Reference in New Issue
Block a user