Tests: handle ConnectionRefusedError in TestUnitHTTP.http().
This commit is contained in:
10
test/unit.py
10
test/unit.py
@@ -154,10 +154,12 @@ class TestUnitHTTP(TestUnit):
|
|||||||
if 'sock' not in kwargs:
|
if 'sock' not in kwargs:
|
||||||
sock = socket.socket(sock_types[sock_type], socket.SOCK_STREAM)
|
sock = socket.socket(sock_types[sock_type], socket.SOCK_STREAM)
|
||||||
|
|
||||||
if sock_type == 'unix':
|
connect_args = addr if sock_type == 'unix' else (addr, port)
|
||||||
sock.connect(addr)
|
try:
|
||||||
else:
|
sock.connect(connect_args)
|
||||||
sock.connect((addr, port))
|
except ConnectionRefusedError:
|
||||||
|
sock.close()
|
||||||
|
return None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
sock = kwargs['sock']
|
sock = kwargs['sock']
|
||||||
|
|||||||
Reference in New Issue
Block a user