summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-03-15 14:36:39 -0700
committerJoffrey F <f.joffrey@gmail.com>2018-03-15 16:37:58 -0700
commit884261e24103f6732d4f529c19e6f7b56ccf199c (patch)
treecac53effdd2fab94e423f10835aa0dbdf846b45b
parent16ccf377a38548ecdbfe8e2317e2ddcc599c6aea (diff)
downloaddocker-py-884261e24103f6732d4f529c19e6f7b56ccf199c.tar.gz
Fix socket tests for TLS-enabled tests
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--tests/helpers.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index c4ea364..b6b493b 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -108,21 +108,21 @@ def swarm_listen_addr():
def assert_cat_socket_detached_with_keys(sock, inputs):
- if six.PY3:
+ if six.PY3 and hasattr(sock, '_sock'):
sock = sock._sock
for i in inputs:
- sock.send(i)
+ sock.sendall(i)
time.sleep(0.5)
# 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 sock.family == getattr(socket, 'AF_UNIX', -1):
+ if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
with pytest.raises(socket.error):
- sock.send(b'make sure the socket is closed\n')
+ sock.sendall(b'make sure the socket is closed\n')
else:
- sock.send(b"make sure the socket is closed\n")
+ sock.sendall(b"make sure the socket is closed\n")
assert sock.recv(32) == b''