test_host_policy_uses_preexec_on_macos() — langchain Function Reference
Architecture documentation for the test_host_policy_uses_preexec_on_macos() function in test_shell_execution_policies.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2cdaab2e_55db_85c9_963a_c0aed2e8a42b["test_host_policy_uses_preexec_on_macos()"] 6b16168d_9880_7f41_060c_9fcd5b337996["test_shell_execution_policies.py"] 2cdaab2e_55db_85c9_963a_c0aed2e8a42b -->|defined in| 6b16168d_9880_7f41_060c_9fcd5b337996 06707227_971c_bfbd_5596_639762857cca["_make_resource()"] 2cdaab2e_55db_85c9_963a_c0aed2e8a42b -->|calls| 06707227_971c_bfbd_5596_639762857cca style 2cdaab2e_55db_85c9_963a_c0aed2e8a42b 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 112–141
def test_host_policy_uses_preexec_on_macos(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
fake_resource = _make_resource(with_prlimit=False)
monkeypatch.setattr(_execution, "resource", fake_resource, raising=False)
monkeypatch.setattr(sys, "platform", "darwin")
captured: dict[str, Any] = {}
def fake_launch(
*_args: Any, preexec_fn: Callable[[], None] | None, start_new_session: bool, **_kwargs: Any
) -> subprocess.Popen[str]:
captured["preexec_fn"] = preexec_fn
captured["start_new_session"] = start_new_session
return Mock(spec=subprocess.Popen, pid=4321)
monkeypatch.setattr(_execution, "_launch_subprocess", fake_launch)
policy = HostExecutionPolicy(cpu_time_seconds=5, memory_bytes=8192)
env = {"PATH": os.environ.get("PATH", "")}
policy.spawn(workspace=tmp_path, env=env, command=("/bin/sh",))
preexec_fn = captured["preexec_fn"]
assert callable(preexec_fn)
assert captured["start_new_session"] is True
preexec_fn()
# macOS fallback should use setrlimit
assert fake_resource.setrlimit_calls == [
(fake_resource.RLIMIT_CPU, (5, 5)),
(fake_resource.RLIMIT_AS, (8192, 8192)),
]
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_host_policy_uses_preexec_on_macos() do?
test_host_policy_uses_preexec_on_macos() 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_host_policy_uses_preexec_on_macos() defined?
test_host_policy_uses_preexec_on_macos() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_execution_policies.py at line 112.
What does test_host_policy_uses_preexec_on_macos() call?
test_host_policy_uses_preexec_on_macos() calls 1 function(s): _make_resource.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free