File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,8 @@ async def _post_mouse_events(
442
442
# the driver works and emits a click event.
443
443
kwargs = message_arguments
444
444
if mouse_event_cls is Click :
445
- kwargs ["chain" ] = chain
445
+ kwargs = {** kwargs , "chain" : chain }
446
+
446
447
widget_at , _ = app .get_widget_at (* offset )
447
448
event = mouse_event_cls (** kwargs )
448
449
# Bypass event processing in App.on_event. Because App.on_event
Original file line number Diff line number Diff line change 1
1
from string import punctuation
2
+ from typing import Type
2
3
3
4
import pytest
4
5
5
6
from textual import events , work
7
+ from textual ._on import on
6
8
from textual .app import App , ComposeResult
7
9
from textual .binding import Binding
8
10
from textual .containers import Center , Middle
@@ -424,3 +426,27 @@ def on_button_pressed(self):
424
426
assert not pressed
425
427
await pilot .click (button )
426
428
assert pressed
429
+
430
+
431
+ @pytest .mark .parametrize ("times" , [1 , 2 , 3 ])
432
+ async def test_click_times (times : int ):
433
+ """Test that Pilot.click() can be called with a `times` argument."""
434
+
435
+ events_received : list [Type [events .Event ]] = []
436
+
437
+ class TestApp (App [None ]):
438
+ def compose (self ) -> ComposeResult :
439
+ yield Label ("Click counter" )
440
+
441
+ @on (events .Click )
442
+ @on (events .MouseDown )
443
+ @on (events .MouseUp )
444
+ def on_label_clicked (self , event : events .Event ):
445
+ events_received .append (event .__class__ )
446
+
447
+ app = TestApp ()
448
+ async with app .run_test () as pilot :
449
+ await pilot .click (Label , times = times )
450
+ assert (
451
+ events_received == [events .MouseDown , events .MouseUp , events .Click ] * times
452
+ )
You can’t perform that action at this time.
0 commit comments