mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add regression test for #1815.
This commit is contained in:
23
tests/test_pilot.py
Normal file
23
tests/test_pilot.py
Normal 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
|
||||
Reference in New Issue
Block a user