summaryrefslogtreecommitdiff
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-01-29 17:07:15 -0800
committerJoffrey F <joffrey@docker.com>2018-01-30 17:16:23 -0800
commite304f91b4636b59a056ff795d91895c725c6255f (patch)
treeaf96522c00d38e29850ecd8090f427e48030df94 /tests/helpers.py
parentdd858648a0942177995a74e1eda3468a720a3c58 (diff)
downloaddocker-py-e304f91b4636b59a056ff795d91895c725c6255f.tar.gz
Update detach tests to work with AF_INET as wellmtsmfm-master
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 7c68f6d..c4ea364 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -6,8 +6,8 @@ import tarfile
import tempfile
import time
import re
-import socket
import six
+import socket
import docker
import pytest
@@ -107,16 +107,23 @@ def swarm_listen_addr():
return '0.0.0.0:{0}'.format(random.randrange(10000, 25000))
-def assert_socket_closed_with_keys(sock, inputs):
+def assert_cat_socket_detached_with_keys(sock, inputs):
if six.PY3:
sock = sock._sock
for i in inputs:
sock.send(i)
- time.sleep(1)
-
- with pytest.raises(socket.error):
+ 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):
+ with pytest.raises(socket.error):
+ sock.send(b'make sure the socket is closed\n')
+ else:
sock.send(b"make sure the socket is closed\n")
+ assert sock.recv(32) == b''
def ctrl_with(char):