summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2019-04-22 18:01:11 -0700
committerJoffrey F <joffrey@docker.com>2019-05-01 00:35:12 -0700
commit2e67cd1cc7ec4b00afadb9609bb235e3a2f3a0e3 (patch)
treec3a3401867f3a94289247ad2e16868fa26531bfa /tests/helpers.py
parent63cda2e7b58a4dafb1f9f62abf92374e4197c865 (diff)
downloaddocker-py-2e67cd1cc7ec4b00afadb9609bb235e3a2f3a0e3.tar.gz
Improve socket_detached test helper to support future versions of the daemon
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index f912bd8..9e5d2ab 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -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
# BrokenPipeError ; INET sockets will just stop receiving / sending data
# but will not raise an error
- if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
- with pytest.raises(socket.error):
- sock.sendall(b'make sure the socket is closed\n')
- elif isinstance(sock, paramiko.Channel):
+ if isinstance(sock, paramiko.Channel):
with pytest.raises(OSError):
sock.sendall(b'make sure the socket is closed\n')
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")
data = sock.recv(128)
# New in 18.06: error message is broadcast over the socket when reading