mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
remove some pauses
This commit is contained in:
@@ -34,13 +34,16 @@ class Pilot(Generic[ReturnType]):
|
||||
if keys:
|
||||
await self._app._press_keys(keys)
|
||||
|
||||
async def pause(self, delay: float = 50 / 1000) -> None:
|
||||
async def pause(self, delay: float | None = None) -> None:
|
||||
"""Insert a pause.
|
||||
|
||||
Args:
|
||||
delay: Seconds to pause. Defaults to 50ms.
|
||||
delay: Seconds to pause, or None to wait for cpu idle. Defaults to None.
|
||||
"""
|
||||
# These sleep zeros, are to force asyncio to give up a time-slice,
|
||||
if delay is None:
|
||||
await wait_for_idle(0)
|
||||
else:
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
async def wait_for_animation(self) -> None:
|
||||
|
||||
@@ -31,10 +31,8 @@ async def test_empty_inherited_list_view() -> None:
|
||||
"""An empty self-populating inherited ListView should work as expected."""
|
||||
async with ListViewApp().run_test() as pilot:
|
||||
await pilot.press("tab")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.query_one(MyListView).index is None
|
||||
await pilot.press("down")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.query_one(MyListView).index is None
|
||||
|
||||
|
||||
@@ -42,8 +40,6 @@ async def test_populated_inherited_list_view() -> None:
|
||||
"""A self-populating inherited ListView should work as normal."""
|
||||
async with ListViewApp(30).run_test() as pilot:
|
||||
await pilot.press("tab")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.query_one(MyListView).index == 0
|
||||
await pilot.press("down")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.query_one(MyListView).index == 1
|
||||
|
||||
@@ -14,7 +14,6 @@ def test_auto_pilot() -> None:
|
||||
async def auto_pilot(pilot: Pilot) -> None:
|
||||
|
||||
await pilot.press("tab", *"foo")
|
||||
await pilot.pause(1 / 100)
|
||||
await pilot.exit("bar")
|
||||
|
||||
app = TestApp()
|
||||
|
||||
@@ -238,7 +238,7 @@ async def test_pressing_alpha_on_app() -> None:
|
||||
"""Test that pressing the alpha key, when it's bound on the app, results in an action fire."""
|
||||
async with AppWithMovementKeysBound().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALPHAS)
|
||||
await pilot.pause(2 / 100)
|
||||
await pilot.pause()
|
||||
assert pilot.app.pressed_keys == [*AppKeyRecorder.ALPHAS]
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ async def test_pressing_movement_keys_app() -> None:
|
||||
"""Test that pressing the movement keys, when they're bound on the app, results in an action fire."""
|
||||
async with AppWithMovementKeysBound().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
await pilot.pause()
|
||||
pilot.app.all_recorded()
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ async def test_focused_child_widget_with_movement_bindings() -> None:
|
||||
"""A focused child widget with movement bindings should handle its own actions."""
|
||||
async with AppWithWidgetWithBindings().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
|
||||
pilot.app.all_recorded("locally_")
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ async def test_focused_child_widget_with_movement_bindings_on_screen() -> None:
|
||||
"""A focused child widget, with movement bindings in the screen, should trigger screen actions."""
|
||||
async with AppWithScreenWithBindingsWidgetNoBindings().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
|
||||
pilot.app.all_recorded("screenly_")
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ async def test_contained_focused_child_widget_with_movement_bindings_on_screen()
|
||||
"""A contained focused child widget, with movement bindings in the screen, should trigger screen actions."""
|
||||
async with AppWithScreenWithBindingsWrappedWidgetNoBindings().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
|
||||
pilot.app.all_recorded("screenly_")
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ async def test_focused_child_widget_with_movement_bindings_no_inherit() -> None:
|
||||
"""A focused child widget with movement bindings and inherit_bindings=False should handle its own actions."""
|
||||
async with AppWithWidgetWithBindingsNoInherit().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
|
||||
pilot.app.all_recorded("locally_")
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ async def test_focused_child_widget_no_inherit_with_movement_bindings_on_screen(
|
||||
"""A focused child widget, that doesn't inherit bindings, with movement bindings in the screen, should trigger screen actions."""
|
||||
async with AppWithScreenWithBindingsWidgetNoBindingsNoInherit().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
|
||||
pilot.app.all_recorded("screenly_")
|
||||
|
||||
|
||||
@@ -520,7 +520,6 @@ async def test_focused_child_widget_no_inherit_empty_bindings_with_movement_bind
|
||||
"""A focused child widget, that doesn't inherit bindings and sets BINDINGS empty, with movement bindings in the screen, should trigger screen actions."""
|
||||
async with AppWithScreenWithBindingsWidgetEmptyBindingsNoInherit().run_test() as pilot:
|
||||
await pilot.press(*AppKeyRecorder.ALL_KEYS)
|
||||
await pilot.pause(2 / 100)
|
||||
pilot.app.all_recorded("screenly_")
|
||||
|
||||
|
||||
@@ -602,7 +601,6 @@ async def test_overlapping_priority_bindings() -> None:
|
||||
"""Test an app stack with overlapping bindings."""
|
||||
async with PriorityOverlapApp().run_test() as pilot:
|
||||
await pilot.press(*"0abcdef")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.pressed_keys == [
|
||||
"widget_0",
|
||||
"app_a",
|
||||
|
||||
@@ -40,5 +40,4 @@ async def test_toggle_dark_in_action() -> None:
|
||||
"""It should be possible to toggle dark mode with an action."""
|
||||
async with OnMountDarkSwitch().run_test() as pilot:
|
||||
await pilot.press("d")
|
||||
await pilot.pause(2 / 100)
|
||||
assert not pilot.app.dark
|
||||
|
||||
@@ -16,7 +16,6 @@ async def test_run_test() -> None:
|
||||
str(pilot) == "<Pilot app=TestApp(title='TestApp', classes={'-dark-mode'})>"
|
||||
)
|
||||
await pilot.press("tab", *"foo")
|
||||
await pilot.pause(1 / 100)
|
||||
await pilot.exit("bar")
|
||||
|
||||
assert app.return_value == "bar"
|
||||
|
||||
@@ -45,7 +45,6 @@ async def test_tree_node_selected_message() -> None:
|
||||
"""Selecting a node should result in a selected message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("enter")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.messages == ["NodeExpanded", "NodeSelected"]
|
||||
|
||||
|
||||
@@ -53,7 +52,6 @@ async def test_tree_node_expanded_message() -> None:
|
||||
"""Expanding a node should result in an expanded message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("enter")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.messages == ["NodeExpanded", "NodeSelected"]
|
||||
|
||||
|
||||
@@ -61,7 +59,6 @@ async def test_tree_node_collapsed_message() -> None:
|
||||
"""Collapsing a node should result in a collapsed message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("enter", "enter")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.messages == [
|
||||
"NodeExpanded",
|
||||
"NodeSelected",
|
||||
@@ -74,5 +71,4 @@ async def test_tree_node_highlighted_message() -> None:
|
||||
"""Highlighting a node should result in a highlighted message being emitted."""
|
||||
async with TreeApp().run_test() as pilot:
|
||||
await pilot.press("enter", "down")
|
||||
await pilot.pause(2 / 100)
|
||||
assert pilot.app.messages == ["NodeExpanded", "NodeSelected", "NodeHighlighted"]
|
||||
|
||||
Reference in New Issue
Block a user