mirror of https://github.com/docker/docker-py.git
Improve socket_detached test helper to support future versions of the daemon
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
63cda2e7b5
commit
2e67cd1cc7
|
@ -119,13 +119,18 @@ def assert_cat_socket_detached_with_keys(sock, inputs):
|
||||||
# If we're using a Unix socket, the sock.send call will fail with a
|
# If we're using a Unix socket, the sock.send call will fail with a
|
||||||
# BrokenPipeError ; INET sockets will just stop receiving / sending data
|
# BrokenPipeError ; INET sockets will just stop receiving / sending data
|
||||||
# but will not raise an error
|
# but will not raise an error
|
||||||
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
|
if isinstance(sock, paramiko.Channel):
|
||||||
with pytest.raises(socket.error):
|
|
||||||
sock.sendall(b'make sure the socket is closed\n')
|
|
||||||
elif isinstance(sock, paramiko.Channel):
|
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
sock.sendall(b'make sure the socket is closed\n')
|
sock.sendall(b'make sure the socket is closed\n')
|
||||||
else:
|
else:
|
||||||
|
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
|
||||||
|
# We do not want to use pytest.raises here because future versions
|
||||||
|
# of the daemon no longer cause this to raise an error.
|
||||||
|
try:
|
||||||
|
sock.sendall(b'make sure the socket is closed\n')
|
||||||
|
except socket.error:
|
||||||
|
return
|
||||||
|
|
||||||
sock.sendall(b"make sure the socket is closed\n")
|
sock.sendall(b"make sure the socket is closed\n")
|
||||||
data = sock.recv(128)
|
data = sock.recv(128)
|
||||||
# New in 18.06: error message is broadcast over the socket when reading
|
# New in 18.06: error message is broadcast over the socket when reading
|
||||||
|
|
Loading…
Reference in New Issue