diff options
| author | Joffrey F <f.joffrey@gmail.com> | 2019-05-01 00:57:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-01 00:57:27 -0700 |
| commit | 992e0dcdfbe27fbe8c1476aff6e67b0208f4e0e7 (patch) | |
| tree | 78b771da47263a1e7b2dcab2cd4bfa6e48857ee0 | |
| parent | 63cda2e7b58a4dafb1f9f62abf92374e4197c865 (diff) | |
| parent | 62c8bcbbb600cbe26e3e12ed95207ffe63c40fc8 (diff) | |
| download | docker-py-992e0dcdfbe27fbe8c1476aff6e67b0208f4e0e7.tar.gz | |
Merge pull request #2317 from docker/fix_socket_detach_helper
Fix socket detach helper
| -rw-r--r-- | tests/helpers.py | 19 | ||||
| -rw-r--r-- | tests/integration/api_container_test.py | 2 |
2 files changed, 13 insertions, 8 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index f912bd8..f344e1c 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -2,16 +2,16 @@ import functools import os import os.path import random +import re +import socket import tarfile import tempfile import time -import re -import six -import socket import docker import paramiko import pytest +import six def make_tree(dirs, files): @@ -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 diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py index 730c9ee..9b770c7 100644 --- a/tests/integration/api_container_test.py +++ b/tests/integration/api_container_test.py @@ -1251,7 +1251,7 @@ class AttachContainerTest(BaseAPIIntegrationTest): output = self.client.attach(container, stream=False, logs=True) assert output == 'hello\n'.encode(encoding='ascii') - @pytest.mark.timeout(5) + @pytest.mark.timeout(10) @pytest.mark.skipif(os.environ.get('DOCKER_HOST', '').startswith('ssh://'), reason='No cancellable streams over SSH') def test_attach_stream_and_cancel(self): |
