Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
from __future__ import annotations

import pytest
from prompt_toolkit.application import create_app_session
from prompt_toolkit.input import create_pipe_input
from prompt_toolkit.output import DummyOutput

from fast_agent.integrations import herdr_lifecycle


@pytest.fixture(autouse=True)
def isolate_prompt_toolkit_app_session():
"""Give every test its own prompt_toolkit app session, detached from the terminal.

Building a prompt_toolkit Application binds the ambient AppSession's output,
and constructing that output probes the terminal. Under pytest's captured
stdout on Windows the probe raises NoConsoleScreenBufferError, so every test
that builds UI fails there — while Linux CI never sees it, because the POSIX
Vt100 output has no equivalent probe.

Binding a DummyOutput and a pipe input makes the session explicit rather than
ambient, which is also what keeps these tests from touching the real terminal
when they are run locally.
"""
with create_pipe_input() as pipe_input:
with create_app_session(input=pipe_input, output=DummyOutput()):
yield


@pytest.fixture(autouse=True)
def isolate_herdr_lifecycle(monkeypatch: pytest.MonkeyPatch):
"""Prevent tests run inside Herdr from reporting against the developer's pane."""
Expand Down
Loading