Files
textual/tests/test_call_later.py
Will McGugan 80f4c12e76 Fix scroll flicker (#2358)
* fix scroll flicker

* fix scroll flicker

* remove event

* do not delay scroll

* remove comment

* test fix

* remove commented code

* comment

* increase pause on click

* changelog [skip ci]

* wait on resume

* remove note [skip ci]
2023-04-24 09:33:15 +01:00

43 lines
1.0 KiB
Python

import asyncio
from textual.app import App
class CallLaterApp(App[None]):
def __init__(self) -> None:
self.display_count = 0
super().__init__()
def post_display_hook(self) -> None:
self.display_count += 1
async def test_call_later() -> None:
"""Check that call later makes a call."""
app = CallLaterApp()
called_event = asyncio.Event()
async with app.run_test():
app.call_later(called_event.set)
await asyncio.wait_for(called_event.wait(), 1)
async def test_call_after_refresh() -> None:
"""Check that call later makes a call after a refresh."""
app = CallLaterApp()
display_count = -1
called_event = asyncio.Event()
def callback() -> None:
nonlocal display_count
called_event.set()
display_count = app.display_count
async with app.run_test():
app.call_after_refresh(callback)
await asyncio.wait_for(called_event.wait(), 1)
app_display_count = app.display_count
assert app_display_count == display_count