MCPcopy Create free account
hub / github.com/dagger/dagger / test_exec_error

Function test_exec_error

sdk/python/tests/client/test_execute_errors.py:98–126  ·  view source on GitHub ↗
(client: dagger.Client, httpx_mock: HTTPXMock)

Source from the content-addressed store, hash-verified

96
97
98async def test_exec_error(client: dagger.Client, httpx_mock: HTTPXMock):
99 error = {
100 "message": "command not found",
101 "path": ["container", "from", "withExec"],
102 "locations": [{"line": 3, "column": 5}],
103 "extensions": {
104 "_type": "EXEC_ERROR",
105 "cmd": ["sh", "-c", "spam"],
106 "exitCode": 127,
107 "stdout": "",
108 "stderr": "/bin/sh: spam: not found",
109 },
110 }
111 httpx_mock.add_response(json={"errors": [error]})
112 ctr = client.container().from_("alpine").with_exec(["sh", "-c", "spam"])
113
114 with pytest.raises(dagger.ExecError) as exc_info:
115 await ctr
116
117 exc = exc_info.value
118 assert issubclass(exc.__class__, dagger.QueryError)
119
120 assert exc.message == "command not found"
121 assert exc.command == ["sh", "-c", "spam"]
122 assert exc.exit_code == 127
123 assert exc.stderr == "/bin/sh: spam: not found"
124 assert exc.stdout == ""
125
126 assert "command not found" in str(exc)

Callers

nothing calls this directly

Calls 3

from_Method · 0.80
with_execMethod · 0.45
containerMethod · 0.45

Tested by

no test coverage detected