Skip to content

Commit c6c8b8e

Browse files
committed
test
1 parent c0910a6 commit c6c8b8e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_message_pump.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import threading
2+
13
import pytest
24

35
from textual._dispatch_key import dispatch_key
@@ -169,3 +171,22 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
169171
async with app.run_test() as pilot:
170172
await pilot.click(MyButton)
171173
assert app_button_pressed
174+
175+
176+
async def test_thread_safe_post_message():
177+
class TextMessage(Message):
178+
pass
179+
180+
class TestApp(App):
181+
182+
def on_mount(self) -> None:
183+
msg = TextMessage()
184+
threading.Thread(target=self.post_message, args=(msg,)).start()
185+
186+
def on_text_message(self, message):
187+
self.exit()
188+
189+
app = TestApp()
190+
191+
async with app.run_test() as pilot:
192+
await pilot.pause()

0 commit comments

Comments
 (0)