From 3235d5c6aa9216326b9623791e033bbce7c7765a Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Fri, 27 Sep 2024 15:05:08 +0100 Subject: [PATCH] tests/exec: add test for exit code from exec Execs should return the exit code of the exec'd process, if it started. Signed-off-by: Laura Brehm --- tests/integration/models_containers_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py index bb6468517..d20695067 100644 --- a/tests/integration/models_containers_test.py +++ b/tests/integration/models_containers_test.py @@ -353,6 +353,15 @@ def test_exec_run_success(self): assert exec_output[0] == 0 assert exec_output[1] == b"hello\n" + def test_exec_run_error_code_from_exec(self): + client = docker.from_env(version=TEST_API_VERSION) + container = client.containers.run( + "alpine", "sleep 20'", detach=True + ) + self.tmp_containers.append(container.id) + exec_output = container.exec_run("exit 42") + assert exec_output[0] == 42 + def test_exec_run_failed(self): client = docker.from_env(version=TEST_API_VERSION) container = client.containers.run(