mirror of https://github.com/docker/docker-py.git
Display stack trace when tty is enabled
Signed-off-by: Gavin D'mello <dmellogavin5000@gmail.com>
This commit is contained in:
parent
a0b9c3d0b3
commit
a494201e6f
|
@ -823,7 +823,10 @@ class ContainerCollection(Collection):
|
|||
if exit_status != 0:
|
||||
out = None
|
||||
if not kwargs.get('auto_remove'):
|
||||
out = container.logs(stdout=False, stderr=True)
|
||||
if not kwargs.get('tty'):
|
||||
out = container.logs(stdout=False, stderr=True)
|
||||
else:
|
||||
out = container.logs(stdout=True, stderr=True)
|
||||
|
||||
if remove:
|
||||
container.remove()
|
||||
|
|
|
@ -35,6 +35,15 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
|||
assert "alpine" in cm.exconly()
|
||||
assert "No such file or directory" in cm.exconly()
|
||||
|
||||
def test_run_with_error_with_tty(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
with pytest.raises(docker.errors.ContainerError) as cm:
|
||||
client.containers.run("alpine", "cat /test", remove=True, tty=True)
|
||||
assert cm.value.exit_status == 1
|
||||
assert "cat /test" in cm.exconly()
|
||||
assert "alpine" in cm.exconly()
|
||||
assert "No such file or directory" in cm.exconly()
|
||||
|
||||
def test_run_with_image_that_does_not_exist(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
with pytest.raises(docker.errors.ImageNotFound):
|
||||
|
|
|
@ -246,6 +246,16 @@ class ContainerCollectionTest(unittest.TestCase):
|
|||
assert cm.value.exit_status == 1
|
||||
assert "some error" in cm.exconly()
|
||||
|
||||
def test_run_with_error_and_tty(self):
|
||||
client = make_fake_client()
|
||||
client.api.logs.return_value = "some error"
|
||||
client.api.wait.return_value = {'StatusCode': 1}
|
||||
|
||||
with pytest.raises(docker.errors.ContainerError) as cm:
|
||||
client.containers.run('alpine', 'echo hello world', tty=True)
|
||||
assert cm.value.exit_status == 1
|
||||
assert "some error" in cm.exconly()
|
||||
|
||||
def test_run_with_image_object(self):
|
||||
client = make_fake_client()
|
||||
image = client.images.get(FAKE_IMAGE_ID)
|
||||
|
|
Loading…
Reference in New Issue