Add regression test for #1815.

This commit is contained in:
Rodrigo Girão Serrão
2023-03-02 17:21:19 +00:00
parent 9b6f1c4dcf
commit b6b76025d0

23
tests/test_pilot.py Normal file
View File

@@ -0,0 +1,23 @@
from string import punctuation
from textual import events
from textual.app import App
KEY_CHARACTERS_TO_TEST = "akTW03" + punctuation.replace("_", "")
"""Test some "simple" characters (letters + digits) and all punctuation.
Ignore the underscore because that is an alias to add a pause in the pilot.
"""
async def test_pilot_press_ascii_chars():
"""Test that the pilot can press most ASCII characters as keys."""
keys_pressed = []
class TestApp(App[None]):
def on_key(self, event: events.Key) -> None:
keys_pressed.append(event.character)
async with TestApp().run_test() as pilot:
for char in KEY_CHARACTERS_TO_TEST:
await pilot.press(char)
assert keys_pressed[-1] == char