From f7a1ee49a42c58ba315c8957b45a80d862ffe745 Mon Sep 17 00:00:00 2001 From: David Perl Date: Mon, 20 Apr 2026 13:00:12 +0200 Subject: [PATCH] fix: don't assume attr exists if we timed out waiting for it --- tests/end-2-end/conftest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/end-2-end/conftest.py b/tests/end-2-end/conftest.py index d628dec5..afe024ce 100644 --- a/tests/end-2-end/conftest.py +++ b/tests/end-2-end/conftest.py @@ -33,7 +33,7 @@ def threads_check_fixture(threads_check): @pytest.fixture def gui_id(): """New gui id each time, to ensure no 'gui is alive' zombie key can perturb""" - return f"figure_{random.randint(0,100)}" # make a new gui id each time, to ensure no 'gui is alive' zombie key can perturb + return f"figure_{random.randint(0, 100)}" # make a new gui id each time, to ensure no 'gui is alive' zombie key can perturb @pytest.fixture(scope="function") @@ -51,6 +51,7 @@ def connected_client_gui_obj(qtbot, gui_id, bec_client_lib): qtbot.waitUntil(lambda: len(gui.bec.widget_list()) == 0, timeout=10000) yield gui finally: - gui.bec.delete_all() # ensure clean state - qtbot.waitUntil(lambda: len(gui.bec.widget_list()) == 0, timeout=10000) + if (bec := getattr(gui, "bec", None)) is not None: + bec.delete_all() # ensure clean state + qtbot.waitUntil(lambda: len(bec.widget_list()) == 0, timeout=10000) gui.kill_server()