27 lines
657 B
Python
27 lines
657 B
Python
import sys
|
|
|
|
import pytest
|
|
|
|
from takopi.runners import codex
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_manage_subprocess_kills_when_terminate_times_out(
|
|
monkeypatch,
|
|
) -> None:
|
|
async def fake_wait_for_process(_proc, timeout: float) -> bool:
|
|
_ = timeout
|
|
return True
|
|
|
|
monkeypatch.setattr(codex, "_wait_for_process", fake_wait_for_process)
|
|
|
|
async with codex.manage_subprocess(
|
|
sys.executable,
|
|
"-c",
|
|
"import signal, time; signal.signal(signal.SIGTERM, signal.SIG_IGN); time.sleep(10)",
|
|
) as proc:
|
|
assert proc.returncode is None
|
|
|
|
assert proc.returncode is not None
|
|
assert proc.returncode != 0
|