Skip to content

Commit

Permalink
tests/exec: add test for exit code from exec
Browse files Browse the repository at this point in the history
Execs should return the exit code of the exec'd process, if it started.

Signed-off-by: Laura Brehm <[email protected]>
  • Loading branch information
laurazard committed Sep 27, 2024
1 parent 96ef4d3 commit cd2d263
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/integration/models_containers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit cd2d263

Please sign in to comment.