diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-02-19 00:30:37 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-02-19 00:30:37 +0100 |
commit | 2bec6a35e211422c61a5404ec6a8c7572c318b54 (patch) | |
tree | 1865b6a3acf374bd46bd1ef864c4e87dc9f2808e | |
parent | ecb26c3c822ff4f4c61233c8265faed666625677 (diff) | |
download | mitmproxy-2bec6a35e211422c61a5404ec6a8c7572c318b54.tar.gz mitmproxy-2bec6a35e211422c61a5404ec6a8c7572c318b54.tar.bz2 mitmproxy-2bec6a35e211422c61a5404ec6a8c7572c318b54.zip |
fix #956
-rw-r--r-- | netlib/tcp.py | 6 | ||||
-rw-r--r-- | test/netlib/test_tcp.py | 10 |
2 files changed, 5 insertions, 11 deletions
diff --git a/netlib/tcp.py b/netlib/tcp.py index 61b41cdc..6423888a 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -355,9 +355,6 @@ class Address(utils.Serializable): def __repr__(self): return "{}:{}".format(self.host, self.port) - def __str__(self): - return str(self.address) - def __eq__(self, other): if not other: return False @@ -698,8 +695,7 @@ class TCPClient(_Connection): if self.source_address: connection.bind(self.source_address()) connection.connect(self.address()) - if not self.source_address: - self.source_address = Address(connection.getsockname()) + self.source_address = Address(connection.getsockname()) except (socket.error, IOError) as err: raise TcpException( 'Error connecting to "%s": %s' % diff --git a/test/netlib/test_tcp.py b/test/netlib/test_tcp.py index e65a2e2f..4b4bbb92 100644 --- a/test/netlib/test_tcp.py +++ b/test/netlib/test_tcp.py @@ -748,17 +748,15 @@ class TestPeekSSL(TestPeek): class TestAddress: - def test_simple(self): - a = tcp.Address("localhost", True) + a = tcp.Address(("localhost", 80), True) assert a.use_ipv6 - b = tcp.Address("foo.com", True) + b = tcp.Address(("foo.com", 80), True) assert not a == b - assert str(b) == str(tuple("foo.com")) - c = tcp.Address("localhost", True) + c = tcp.Address(("localhost", 80), True) assert a == c assert not a != c - assert repr(a) + assert repr(a) == "localhost:80" class TestSSLKeyLogger(tservers.ServerTestBase): |