Skip to content

Commit 5dff472

Browse files
committed
tests: test_show_typing_notification: Partially stabilize test_show_typing_notification.
Used a background thread to reduce timing flakiness in test_show_typing_notification. While this improves stability, the loop timing still depends on the Timer clearing active_conversation_info, so the test can intermittently fail. (time.sleep added to show_typing_notification to reproduce flaky bug more reliably. Will be deleted once bug is resolved)
1 parent ea63c32 commit 5dff472

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tests/core/test_core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,9 @@ def mock_typing() -> None:
597597
controller.active_conversation_info = {}
598598

599599
Timer(0.1, mock_typing).start()
600-
Thread(controller.show_typing_notification()).start()
600+
thread = Thread(target=controller.show_typing_notification)
601+
thread.start()
602+
thread.join(timeout=1)
601603

602604
if active_conversation_info:
603605
set_footer_text.assert_has_calls(

zulipterminal/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ def show_typing_notification(self) -> None:
451451

452452
# Until conversation becomes "inactive" like when a `stop` event is sent
453453
while self.active_conversation_info:
454+
time.sleep(0.5) #To reproduce flakey test
454455
sender_name = self.active_conversation_info["sender_name"]
455456
self.view.set_footer_text(
456457
[

0 commit comments

Comments
 (0)