Problem: Tests bestehen im Ausführungsmodus, schlagen jedoch im Debugmodus mit Qt fehl (PySide6 – Python)Python

Python-Programme
Anonymous
 Problem: Tests bestehen im Ausführungsmodus, schlagen jedoch im Debugmodus mit Qt fehl (PySide6 – Python)

Post by Anonymous »

Ich stoße bei meinen Unit-Tests mit einer Qt-basierten Benutzeroberfläche auf ein seltsames Problem. Alle meine Tests funktionieren im Ausführungsmodus einwandfrei, aber sobald ich in den Debug-Modus wechsle und irgendwo in meinem Code einen Haltepunkt setze, schlagen die Tests fehl.
Es scheint, dass das Problem damit zusammenhängt Die Qt-Schnittstelle „friert“ ein, wenn ein Haltepunkt erreicht wird, und sie „taut nicht auf“, sodass die Tests nicht fortgesetzt werden können.
Hier ist ein Ausschnitt des problematischen Codes:

Code: Select all

def click_next_from_creation_plg(ctrl: Controller, qt_bot: QtBot, expected_res: bool):
"""
Click on next button from plugin creation panel and check if it's active

:param ctrl: Application controller
:param qt_bot: (QtBot) qt test fixture instance
:param expected_res: expected result on click, true if the button work, false else it doesn't work
:return: None
"""
current_page = ctrl.gui.stackedWidget.currentIndex()
if ctrl.main_window is not None and ctrl.main_window.isVisible():
if expected_res:
QTest.mouseClick(ctrl.create_panel.gui.button_next, Qt.MouseButton.LeftButton)
qt_bot.waitUntil(lambda: ctrl.gui.stackedWidget.currentIndex() != current_page, timeout=WAITING_QTBOT)
assert current_page != ctrl.gui.stackedWidget.currentIndex(), ("The current page should change when "
"the next button is clicked.")
else:
with qt_bot.assertNotEmitted(ctrl.create_panel.nextClicked):
QTest.mouseClick(ctrl.create_panel.gui.button_next, Qt.MouseButton.LeftButton)
assert current_page == ctrl.gui.stackedWidget.currentIndex(), ("The current page should not change "
"when the next button is clicked but "
"is not functional.")

assert ctrl.gui.button_next.isEnabled() is expected_res, ("The next button's enabled state does not match the "
"expected result.")
Und das ist die Fehlermeldung:

Code: Select all

def click_next_from_creation_plg(ctrl: Controller, qt_bot: QtBot, expected_res: bool):
"""
Click on next button from plugin creation panel and check if it's active

:param ctrl: Application controller
:param qt_bot: (QtBot) qt test fixture instance
:param expected_res: expected result on click, true if the button work, false else it doesn't work
:return: None
"""
current_page = ctrl.gui.stackedWidget.currentIndex()
if ctrl.main_window is not None and ctrl.main_window.isVisible():
if expected_res:
QTest.mouseClick(ctrl.create_panel.gui.button_next, Qt.MouseButton.LeftButton)
>               qt_bot.waitUntil(lambda: ctrl.gui.stackedWidget.currentIndex() != current_page, timeout=WAITING_QTBOT)
E               pytestqt.exceptions.TimeoutError: waitUntil timed out in 5000 milliseconds

tools.py:164: TimeoutError
Vielen Dank im Voraus für Ihre Hilfe! 👌

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post