Skip to content

Commit 2e67cd1

Browse files
committed
Improve socket_detached test helper to support future versions of the daemon
Signed-off-by: Joffrey F <[email protected]>
1 parent 63cda2e commit 2e67cd1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/helpers.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,18 @@ def assert_cat_socket_detached_with_keys(sock, inputs):
119119
# If we're using a Unix socket, the sock.send call will fail with a
120120
# BrokenPipeError ; INET sockets will just stop receiving / sending data
121121
# but will not raise an error
122-
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
123-
with pytest.raises(socket.error):
124-
sock.sendall(b'make sure the socket is closed\n')
125-
elif isinstance(sock, paramiko.Channel):
122+
if isinstance(sock, paramiko.Channel):
126123
with pytest.raises(OSError):
127124
sock.sendall(b'make sure the socket is closed\n')
128125
else:
126+
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
127+
# We do not want to use pytest.raises here because future versions
128+
# of the daemon no longer cause this to raise an error.
129+
try:
130+
sock.sendall(b'make sure the socket is closed\n')
131+
except socket.error:
132+
return
133+
129134
sock.sendall(b"make sure the socket is closed\n")
130135
data = sock.recv(128)
131136
# New in 18.06: error message is broadcast over the socket when reading

0 commit comments

Comments
 (0)