oterm/tests/test_helpers.py
Yiorgis Gozadinos 804c52f786
Make the test wait helper fail when its condition never holds
wait_until returned silently after 80 iterations, so a test whose wait
could never succeed carried on and passed if its later assertions
happened to hold. Two such passes slipped through on this branch. It
now raises TimeoutError, and the whole suite passes with it, so no
existing wait depended on the give-up.
2026-09-27 14:05:35 +03:00

17 lines
529 B
Python

import pytest
from textual.app import App
from tests._helpers import wait_until
async def test_wait_until_raises_when_the_condition_never_holds():
async with App().run_test() as pilot:
with pytest.raises(TimeoutError):
await wait_until(pilot, lambda: False, max_iters=3)
async def test_wait_until_returns_once_the_condition_holds():
seen: list[int] = []
async with App().run_test() as pilot:
await wait_until(pilot, lambda: len(seen.append(1) or seen) >= 2)
assert len(seen) == 2