Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Test PyQt5 GUI Headless on Windows for GitLab CI/CD
QtWS25 Last Chance

Test PyQt5 GUI Headless on Windows for GitLab CI/CD

Scheduled Pinned Locked Moved Unsolved General and Desktop
pyqt5headlessqtqpaplatformqtooltip
1 Posts 1 Posters 570 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adamhendry
    wrote on 30 May 2022, 22:25 last edited by
    #1

    I can run PyQt5 headless by setting the environment variable

    QT_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?

    1 Reply Last reply
    0

    1/1

    30 May 2022, 22:25

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved