Commit f432f0e7 authored by Denis Bilenko's avatar Denis Bilenko

test__socket.py: add test for socket leak in create_connection

parent a7977149
......@@ -143,5 +143,25 @@ if hasattr(socket, 'ssl'):
return sock
class TestCreateConnection(greentest.TestCase):
def test(self):
tempsock1 = socket.socket()
tempsock1.bind(('', 0))
source_port = tempsock1.getsockname()[1]
tempsock2 = socket.socket()
tempsock2.bind(('', 0))
server_port = tempsock2.getsockname()[1]
tempsock1.close()
del tempsock1
tempsock2.close()
del tempsock2
try:
cli = socket.create_connection(('localhost', 4), timeout=30, source_address=('', source_port))
except socket.error, ex:
if 'connection refused' not in str(ex).lower():
raise
if __name__=='__main__':
greentest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment