From fd55a7638ae6608fea644edab275711d01d96690 Mon Sep 17 00:00:00 2001 From: Florian Scherf Date: Thu, 9 Feb 2023 19:13:46 +0100 Subject: [PATCH] tests: fix timing problems in simple daemon test This test crashed frequently in the past, but went back to green when rerun, most of the time. The final check, if the view was stopped correctly, was always the failing check. This seems to be a timing issue, because the browser seems not to wait long enough, before checking if the string `view stopped` appeared. This patch adds an `lona.pytest.eventually` call, to "fix" all timing issues by simply retrying the checks. This is no permanent solution, but will work for now. Signed-off-by: Florian Scherf --- tests/test_daemon_views.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_daemon_views.py b/tests/test_daemon_views.py index 8f94a49f..aa039fa2 100644 --- a/tests/test_daemon_views.py +++ b/tests/test_daemon_views.py @@ -6,6 +6,8 @@ async def test_simple_daemon_view(lona_app_context): from playwright.async_api import async_playwright + from lona.pytest import eventually + def setup_app(app): from datetime import datetime @@ -77,9 +79,12 @@ def handle_request(self, request): # stop view await page.click('#stop') - message3 = await page.inner_text('#message') - assert message3 == 'view stopped' + for attempt in eventually(): + async with attempt: + message3 = await page.inner_text('#message') + + assert message3 == 'view stopped' async def test_multi_tab_daemon_view(lona_app_context):