v2.18.1 (#856)
Co-authored-by: Charles-Edouard Cady <charles.edouard.cady@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Sylvain Afchain <safchain@gmail.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
e607ccbb00
commit
ed5b7192e6
33 changed files with 1456 additions and 125 deletions
|
|
@ -1,10 +1,13 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
import signal
|
||||
import time
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from textual.app import WINDOWS
|
||||
|
||||
from tests.conftest import build_test_vibe_app
|
||||
from vibe.cli.textual_ui.app import VibeApp, _run_app_with_cleanup
|
||||
|
|
@ -249,3 +252,35 @@ async def test_run_app_with_cleanup_runs_cleanup_when_run_async_raises(
|
|||
await _run_app_with_cleanup(app)
|
||||
|
||||
cleanup.assert_awaited_once()
|
||||
|
||||
|
||||
def test_force_quit_delegates_to_private(app: VibeApp) -> None:
|
||||
with patch.object(app, "_force_quit") as private:
|
||||
app._force_quit()
|
||||
|
||||
private.assert_called_once_with()
|
||||
|
||||
|
||||
@pytest.mark.skipif(WINDOWS, reason="SIGTERM handlers are not installed on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_app_with_cleanup_sigterm_triggers_force_quit(app: VibeApp) -> None:
|
||||
captured: list[Callable[[], None]] = []
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
def capture_add(sig: int, callback: Callable[[], None], *args: object) -> None:
|
||||
captured.append(callback)
|
||||
|
||||
async def fake_run_async() -> None:
|
||||
captured[0]()
|
||||
|
||||
with (
|
||||
patch.object(loop, "add_signal_handler", side_effect=capture_add),
|
||||
patch.object(loop, "remove_signal_handler") as remove_handler,
|
||||
patch.object(app, "run_async", side_effect=fake_run_async),
|
||||
patch.object(app, "shutdown_cleanup", new_callable=AsyncMock),
|
||||
patch.object(app, "_force_quit") as force_quit,
|
||||
):
|
||||
await _run_app_with_cleanup(app)
|
||||
|
||||
force_quit.assert_called_once_with()
|
||||
remove_handler.assert_any_call(signal.SIGTERM)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue