Home / Function/ test_codex_policy_spawns_codex_cli() — langchain Function Reference

test_codex_policy_spawns_codex_cli() — langchain Function Reference

Architecture documentation for the test_codex_policy_spawns_codex_cli() function in test_shell_execution_policies.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  302a5e0d_6a25_345c_e336_7ccb35abf44b["test_codex_policy_spawns_codex_cli()"]
  6b16168d_9880_7f41_060c_9fcd5b337996["test_shell_execution_policies.py"]
  302a5e0d_6a25_345c_e336_7ccb35abf44b -->|defined in| 6b16168d_9880_7f41_060c_9fcd5b337996
  style 302a5e0d_6a25_345c_e336_7ccb35abf44b 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 192–231

def test_codex_policy_spawns_codex_cli(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
    recorded: dict[str, list[str]] = {}

    def fake_launch(
        command: Sequence[str],
        *,
        env: Mapping[str, str],
        cwd: Path,
        preexec_fn: Callable[[], None] | None,
        start_new_session: bool,
    ) -> subprocess.Popen[str]:
        recorded["command"] = list(command)
        assert cwd == tmp_path
        assert env["TEST_VAR"] == "1"
        assert preexec_fn is None
        assert not start_new_session
        return Mock()

    monkeypatch.setattr(
        "langchain.agents.middleware._execution._launch_subprocess",
        fake_launch,
    )
    policy = CodexSandboxExecutionPolicy(
        platform="linux",
        config_overrides={"sandbox_permissions": ["disk-full-read-access"]},
    )

    env = {"TEST_VAR": "1"}
    policy.spawn(workspace=tmp_path, env=env, command=("/bin/bash",))

    expected = [
        shutil.which("codex"),
        "sandbox",
        "linux",
        "-c",
        'sandbox_permissions=["disk-full-read-access"]',
        "--",
        "/bin/bash",
    ]
    assert recorded["command"] == expected

Domain

Subdomains

Frequently Asked Questions

What does test_codex_policy_spawns_codex_cli() do?
test_codex_policy_spawns_codex_cli() 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_codex_policy_spawns_codex_cli() defined?
test_codex_policy_spawns_codex_cli() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_execution_policies.py at line 192.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free