From 6ab0f8cf1cd0b43ecb7fda8924ddfe8d19fbcad1 Mon Sep 17 00:00:00 2001 From: "A. Reit" Date: Tue, 7 Jan 2025 13:43:37 +0100 Subject: [PATCH] editor: tests: Fix object lifetime issue detected with PyQt6 Some tests explicitly close the editorstack widget. qtbot also closes the widget after the test finishes. The latter action may fail when "delete on close" flag is set => reset the flag. --- .../editorstack/tests/test_editorstack_and_outline.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spyder/plugins/editor/widgets/editorstack/tests/test_editorstack_and_outline.py b/spyder/plugins/editor/widgets/editorstack/tests/test_editorstack_and_outline.py index 273f4f6a118..60a71ce390d 100644 --- a/spyder/plugins/editor/widgets/editorstack/tests/test_editorstack_and_outline.py +++ b/spyder/plugins/editor/widgets/editorstack/tests/test_editorstack_and_outline.py @@ -16,6 +16,7 @@ # Third party imports import pytest +from qtpy.QtCore import Qt # Local imports from spyder.config.base import running_in_ci @@ -75,6 +76,11 @@ def _create_editorstack(files): editorstack.save_dialog_on_tests = True editorstack.set_outlineexplorer(outlineexplorer) + # Some tests explicitly close the editorstack widget. qtbot also + # closes the widget after the test finishes. The latter action + # may fail when "delete on close" flag is set => clear the flag. + editorstack.setAttribute(Qt.WA_DeleteOnClose, False) + qtbot.addWidget(editorstack) editorstack.show()