diff options
author | Joffrey F <joffrey@docker.com> | 2017-08-21 14:41:10 -0700 |
---|---|---|
committer | Joffrey F <f.joffrey@gmail.com> | 2017-08-22 17:00:11 -0700 |
commit | 0c2b4e4d3aa15efbf2cfac68571e7506ea86b8c9 (patch) | |
tree | 0995a47dff804fb400585bef25f8670e98261492 | |
parent | fc6773d6732a433bda71dde24712584b7885deb8 (diff) | |
download | docker-py-0c2b4e4d3aa15efbf2cfac68571e7506ea86b8c9.tar.gz |
Always send attach request as streaming
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/api/container.py | 2 | ||||
-rw-r--r-- | tests/integration/api_container_test.py | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index dde1325..918f8a3 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -50,7 +50,7 @@ class ContainerApiMixin(object): } u = self._url("/containers/{0}/attach", container) - response = self._post(u, headers=headers, params=params, stream=stream) + response = self._post(u, headers=headers, params=params, stream=True) return self._read_from_socket( response, stream, self._check_is_tty(container) diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py index f8b474a..a972c1c 100644 --- a/tests/integration/api_container_test.py +++ b/tests/integration/api_container_test.py @@ -1092,20 +1092,28 @@ class AttachContainerTest(BaseAPIIntegrationTest): command = "printf '{0}'".format(line) container = self.client.create_container(BUSYBOX, command, detach=True, tty=False) - ident = container['Id'] - self.tmp_containers.append(ident) + self.tmp_containers.append(container) opts = {"stdout": 1, "stream": 1, "logs": 1} - pty_stdout = self.client.attach_socket(ident, opts) + pty_stdout = self.client.attach_socket(container, opts) self.addCleanup(pty_stdout.close) - self.client.start(ident) + self.client.start(container) next_size = next_frame_size(pty_stdout) self.assertEqual(next_size, len(line)) data = read_exactly(pty_stdout, next_size) self.assertEqual(data.decode('utf-8'), line) + def test_attach_no_stream(self): + container = self.client.create_container( + BUSYBOX, 'echo hello' + ) + self.tmp_containers.append(container) + self.client.start(container) + output = self.client.attach(container, stream=False, logs=True) + assert output == 'hello\n'.encode(encoding='ascii') + class PauseTest(BaseAPIIntegrationTest): def test_pause_unpause(self): |