Merge pull request #2037 from Textualize/pilot-click-underscore

Pilot can now press _
This commit is contained in:
Rodrigo Girão Serrão 2023-03-13 14:38:59 +00:00 committed by GitHub
commit 5983d88aa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 13 deletions

View file

@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Changed the `Checkbox` character due to issues with Windows Terminal and Windows 10 https://github.com/Textualize/textual/issues/1934
- Changed the `RadioButton` character due to issues with Windows Terminal and Windows 10 and 11 https://github.com/Textualize/textual/issues/1934
- Changed the `Markdown` initial bullet character due to issues with Windows Terminal and Windows 10 and 11 https://github.com/Textualize/textual/issues/1982
- The underscore `_` is no longer a special alias for the method `pilot.press`
### Added

View file

@ -862,9 +862,7 @@ class App(Generic[ReturnType], DOMNode):
assert driver is not None
await wait_for_idle(0)
for key in keys:
if key == "_":
continue
elif key.startswith("wait:"):
if key.startswith("wait:"):
_, wait_ms = key.split(":")
print(f"(pause {wait_ms}ms)")
await asyncio.sleep(float(wait_ms) / 1000)

View file

@ -1,4 +1,3 @@
from os import terminal_size
from pathlib import Path
import pytest
@ -73,8 +72,7 @@ def test_input_and_focus(snap_compare):
"tab",
*"Darren", # Focus first input, write "Darren"
"tab",
*"Burns",
"_", # Tab focus to second input, write "Burns"
*"Burns", # Focus second input, write "Burns"
]
assert snap_compare(WIDGET_EXAMPLES_DIR / "input.py", press=press)
@ -91,17 +89,17 @@ def test_placeholder_render(snap_compare):
def test_datatable_render(snap_compare):
press = ["tab", "down", "down", "right", "up", "left", "_"]
press = ["tab", "down", "down", "right", "up", "left"]
assert snap_compare(WIDGET_EXAMPLES_DIR / "data_table.py", press=press)
def test_datatable_row_cursor_render(snap_compare):
press = ["up", "left", "right", "down", "down", "_"]
press = ["up", "left", "right", "down", "down"]
assert snap_compare(SNAPSHOT_APPS_DIR / "data_table_row_cursor.py", press=press)
def test_datatable_column_cursor_render(snap_compare):
press = ["left", "up", "down", "right", "right", "_"]
press = ["left", "up", "down", "right", "right"]
assert snap_compare(SNAPSHOT_APPS_DIR / "data_table_column_cursor.py", press=press)

View file

@ -3,10 +3,8 @@ 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.
"""
KEY_CHARACTERS_TO_TEST = "akTW03" + punctuation
"""Test some "simple" characters (letters + digits) and all punctuation."""
async def test_pilot_press_ascii_chars():