Skip to content

API turboframe.testing

rafageist edited this page Dec 4, 2026 · 6 revisions

turboframe.testing

Source: turboframe/testing/init.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

Helpers for an application's tests (pytest and Textual's Pilot).

  • wait_for(pilot, predicate, timeout=, what=): let the app run until the predicate holds, failing after timeout seconds: a bound, not a pause.
  • dialog_ready(app): a TurboFrame dialog is up and takes keys (keys pressed before its focused control is mounted are lost, on a slow runner).
  • isolated_config: a fixture that points the user's configuration and cache folders at temporary ones, so a test never reads or writes the user's. An application's conftest.py says pytest_plugins = ["turboframe.testing"] and asks for it, or wraps it in an autouse fixture of its own.

Contents

dialog_ready, isolated_config, wait_for

dialog_ready

def dialog_ready(app) -> bool

A dialog is up and takes keys: its screen is pushed, the dialog is mounted and done starting (a dialog of turboframe.ui.dialogs: its text selected), and the widget with the focus is mounted. The screen is pushed first; keys pressed before the rest are lost, or replaced when the text is selected after them.

isolated_config

def isolated_config(tmp_path_factory, monkeypatch)

The user's configuration and cache folders (XDG on Linux and macOS, APPDATA and LOCALAPPDATA on Windows) are temporary ones; the configuration folder is returned.

A pytest fixture.

wait_for

async def wait_for(pilot, predicate: Callable[[], bool], *, timeout: float = 10.0, what: str = '') -> None

Let the app run until predicate() holds; fail after timeout seconds (a bound, not a pause).

Clone this wiki locally