mirror of https://github.com/docker/docker-py.git
fix exec api inconsistency
Signed-off-by: Corentin Henry <corentinhenry@gmail.com>
This commit is contained in:
parent
41c0eb7e80
commit
7b3b83dfdb
|
@ -138,15 +138,21 @@ def consume_socket_output(frames, demux=False):
|
|||
|
||||
# If the streams are demultiplexed, the generator yields tuples
|
||||
# (stdout, stderr)
|
||||
out = [six.binary_type(), six.binary_type()]
|
||||
out = [None, None]
|
||||
for frame in frames:
|
||||
# It is guaranteed that for each frame, one and only one stream
|
||||
# is not None.
|
||||
assert frame != (None, None)
|
||||
if frame[0] is not None:
|
||||
out[0] += frame[0]
|
||||
if out[0] is None:
|
||||
out[0] = frame[0]
|
||||
else:
|
||||
out[0] += frame[0]
|
||||
else:
|
||||
out[1] += frame[1]
|
||||
if out[1] is None:
|
||||
out[1] = frame[1]
|
||||
else:
|
||||
out[1] += frame[1]
|
||||
return tuple(out)
|
||||
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ class ExecTest(BaseAPIIntegrationTest):
|
|||
# tty=True, stream=False, demux=True
|
||||
res = self.client.exec_create(id, cmd, tty=True)
|
||||
exec_log = self.client.exec_start(res, demux=True)
|
||||
assert exec_log == (b'hello out\r\nhello err\r\n', b'')
|
||||
assert exec_log == (b'hello out\r\nhello err\r\n', None)
|
||||
|
||||
# tty=True, stream=True, demux=True
|
||||
res = self.client.exec_create(id, cmd, tty=True)
|
||||
|
|
|
@ -574,7 +574,7 @@ class TCPSocketStreamTest(unittest.TestCase):
|
|||
|
||||
def test_read_from_socket_6(self):
|
||||
res = self.request(stream=False, tty=True, demux=True)
|
||||
assert res == (self.stdout_data + self.stderr_data, b'')
|
||||
assert res == (self.stdout_data + self.stderr_data, None)
|
||||
|
||||
def test_read_from_socket_7(self):
|
||||
res = self.request(stream=False, tty=False, demux=False)
|
||||
|
|
Loading…
Reference in New Issue