Test PyQt5 GUI Headless on Windows for GitLab CI/CD
Unsolved
General and Desktop
-
I can run
PyQt5
headless by setting the environment variableQT_QPA_PLATFORM=offscreen
However, I'm not able to pass my test that a tooltip message appears when hovering over a toolbar button. I know this to work because the test passes when I run it in windowed mode:
def test_toolbar_statusbar_and_tooltip_messages(app: MainApp, qtbot: QtBot) -> None: """Test for correct status bar message when a toolbar item is hovered. For example, when the user clicks 'File' in the menubar and hovers over 'New', the statusbar tooltip should read 'Create a new project...'. Args: app (MainApp): (fixture) Qt main application qtbot (QtBot): (fixture) Bot that imitates user interaction """ # Arrange window = app.view statusbar = window.statusbar toolbar = window.toolbar new_action = window.new_action new_rect = toolbar.actionGeometry(new_action) tooltip = QtWidgets.QToolTip # Assert - Precondition assert statusbar.currentMessage() == '' assert tooltip.text() == '' # Act qtbot.mouseMove(toolbar, new_rect.center()) # Assert - Postcondition def check_status(): assert statusbar.currentMessage() == 'Create a new project...' def check_tooltip(): assert tooltip.text() == 'New Project' qtbot.waitUntil(check_status) qtbot.waitUntil(check_tooltip)
Is there a way to test this in headless mode?