From 009270cd69c6d6127dc2d5b3fdd4654f65e32f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:10:22 +0000 Subject: [PATCH 1/3] Remove remaining underscore pauses. These slipped from #2011. --- tests/snapshot_tests/test_snapshots.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 0b26c83c9..d3196ae48 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -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) From 103c27b94295d21bc798d48f53dfcabb0cc24aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:11:33 +0000 Subject: [PATCH 2/3] Add test for pilot pressing underscore. The pilot pressing the underscore '_' used to be an alias for a short pause (see #2011). This test makes sure that the pilot can press the underscore '_' as any other character key. --- tests/test_pilot.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_pilot.py b/tests/test_pilot.py index 2ca527895..04491dea9 100644 --- a/tests/test_pilot.py +++ b/tests/test_pilot.py @@ -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(): From eafa12c9bf2e6578543971ec6d3e80e41284115f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:13:02 +0000 Subject: [PATCH 3/3] Let pilot press _. --- CHANGELOG.md | 1 + src/textual/app.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e1b7eae..2b9b196dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/textual/app.py b/src/textual/app.py index 70c18f2e6..5283e2076 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -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)