test_docker_policy_spawns_docker_run() — langchain Function Reference
Architecture documentation for the test_docker_policy_spawns_docker_run() function in test_shell_execution_policies.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 508ca509_ee34_d8a0_191a_68d49243215a["test_docker_policy_spawns_docker_run()"] 6b16168d_9880_7f41_060c_9fcd5b337996["test_shell_execution_policies.py"] 508ca509_ee34_d8a0_191a_68d49243215a -->|defined in| 6b16168d_9880_7f41_060c_9fcd5b337996 style 508ca509_ee34_d8a0_191a_68d49243215a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_execution_policies.py lines 287–329
def test_docker_policy_spawns_docker_run(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
recorded: dict[str, list[str]] = {}
def fake_launch(
command: Sequence[str],
*,
env: Mapping[str, str],
cwd: Path,
start_new_session: bool,
**_kwargs: Any,
) -> subprocess.Popen[str]:
recorded["command"] = list(command)
assert cwd == tmp_path
assert "PATH" in env # host environment should retain system PATH
assert not start_new_session
return Mock()
monkeypatch.setattr(
"langchain.agents.middleware._execution._launch_subprocess",
fake_launch,
)
policy = DockerExecutionPolicy(
image="ubuntu:22.04",
memory_bytes=4096,
extra_run_args=("--ipc", "host"),
)
env = {"PATH": "/bin"}
policy.spawn(workspace=tmp_path, env=env, command=("/bin/bash",))
command = recorded["command"]
assert command[0] == shutil.which("docker")
assert command[1:4] == ["run", "-i", "--rm"]
assert "--memory" in command
assert "4096" in command
assert "-v" in command
assert any(str(tmp_path) in part for part in command)
assert "-w" in command
w_index = command.index("-w")
assert command[w_index + 1] == str(tmp_path)
assert "-e" in command
assert "PATH=/bin" in command
assert command[-2:] == ["ubuntu:22.04", "/bin/bash"]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_docker_policy_spawns_docker_run() do?
test_docker_policy_spawns_docker_run() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_execution_policies.py.
Where is test_docker_policy_spawns_docker_run() defined?
test_docker_policy_spawns_docker_run() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_execution_policies.py at line 287.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free