test_host_policy_applies_prlimit() — langchain Function Reference
Architecture documentation for the test_host_policy_applies_prlimit() function in test_shell_execution_policies.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 703d5a74_c3d7_7421_4f0b_a44a1a223516["test_host_policy_applies_prlimit()"] 6b16168d_9880_7f41_060c_9fcd5b337996["test_shell_execution_policies.py"] 703d5a74_c3d7_7421_4f0b_a44a1a223516 -->|defined in| 6b16168d_9880_7f41_060c_9fcd5b337996 06707227_971c_bfbd_5596_639762857cca["_make_resource()"] 703d5a74_c3d7_7421_4f0b_a44a1a223516 -->|calls| 06707227_971c_bfbd_5596_639762857cca style 703d5a74_c3d7_7421_4f0b_a44a1a223516 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 74–109
def test_host_policy_applies_prlimit(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
fake_resource = _make_resource(with_prlimit=True)
monkeypatch.setattr(_execution, "resource", fake_resource, raising=False)
monkeypatch.setattr(sys, "platform", "linux")
recorded: dict[str, Any] = {}
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)
recorded["env"] = dict(env)
recorded["cwd"] = cwd
recorded["preexec_fn"] = preexec_fn
recorded["start_new_session"] = start_new_session
return Mock(spec=subprocess.Popen, pid=1234)
monkeypatch.setattr(_execution, "_launch_subprocess", fake_launch)
policy = HostExecutionPolicy(cpu_time_seconds=2, memory_bytes=4096)
env = {"PATH": os.environ.get("PATH", ""), "VAR": "1"}
process = policy.spawn(workspace=tmp_path, env=env, command=("/bin/sh",))
assert process is not None
assert recorded["preexec_fn"] is None
assert recorded["start_new_session"] is True
assert fake_resource.prlimit_calls == [
(1234, fake_resource.RLIMIT_CPU, (2, 2)),
(1234, fake_resource.RLIMIT_AS, (4096, 4096)),
]
assert fake_resource.setrlimit_calls == []
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_host_policy_applies_prlimit() do?
test_host_policy_applies_prlimit() 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_applies_prlimit() defined?
test_host_policy_applies_prlimit() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_shell_execution_policies.py at line 74.
What does test_host_policy_applies_prlimit() call?
test_host_policy_applies_prlimit() 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