Skip to content

Commit ffdc048

Browse files
committed
Fix socket tests for TLS-enabled tests
Signed-off-by: Joffrey F <[email protected]>
1 parent cf1d869 commit ffdc048

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@ def swarm_listen_addr():
108108

109109

110110
def assert_cat_socket_detached_with_keys(sock, inputs):
111-
if six.PY3:
111+
if six.PY3 and hasattr(sock, '_sock'):
112112
sock = sock._sock
113113

114114
for i in inputs:
115-
sock.send(i)
115+
sock.sendall(i)
116116
time.sleep(0.5)
117117

118118
# If we're using a Unix socket, the sock.send call will fail with a
119119
# BrokenPipeError ; INET sockets will just stop receiving / sending data
120120
# but will not raise an error
121-
if sock.family == getattr(socket, 'AF_UNIX', -1):
121+
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
122122
with pytest.raises(socket.error):
123-
sock.send(b'make sure the socket is closed\n')
123+
sock.sendall(b'make sure the socket is closed\n')
124124
else:
125-
sock.send(b"make sure the socket is closed\n")
125+
sock.sendall(b"make sure the socket is closed\n")
126126
assert sock.recv(32) == b''
127127

128128

0 commit comments

Comments
 (0)