question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues when runnning tests with Xvfb

See original GitHub issue

Hi,

I am trying to run some tests with pytest-qt using Travis and to simulate at my workstation the same issue I am using pytest-xvfb.

The following test works when running at my computer without the Xvfb but something very similar fails at Travis and also at my computer when using Xvfb.

from PyQt5.QtWidgets import QLineEdit

def test_focus(qtbot):
    line_edit = QLineEdit()
    qtbot.addWidget(line_edit)
    with qtbot.waitExposed(line_edit):
        line_edit.show()

    line_edit.setFocus()

    qtbot.waitUntil(lambda: line_edit.hasFocus())

    assert line_edit.hasFocus()

I tried to follow the same as the solution on this issue in here: https://github.com/pytest-dev/pytest-qt/issues/160 but no lucky so far.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
hhslepickacommented, Apr 27, 2018

Thank you @nicoddemus and @The-Compiler for the input. It was really an issue of not having the window manager.

Here is what did the trick for me:

sudo: required

before_install:
  - sudo apt-get update
  - sudo apt-get install -y xvfb herbstluftwm
  -...

install:
  - "export DISPLAY=:99.0"
  - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX +render -noreset"
  - sleep 3

before_script:
  - "herbstluftwm &"
  - sleep 1

Now all my tests are passing and working as expected. Thank you for this great tool! 👍

1reaction
hhslepickacommented, Apr 27, 2018

Sure! I’m just not sure if I added it to the best place but here it is: https://github.com/pytest-dev/pytest-qt/pull/207 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

38 How To Run Your Tests Headlessly with Xvfb
If you're running tests headlessly across different builds at the same time (e.g., in parallel) on your CI server, then jobs will start...
Read more >
Running tests with xvfb-run - Development - VTK Discourse
Hello, PROBLEM: I'm trying to run VTK testing through xvfb-run ctest and many of the tests (complete list of failed tests) end up...
Read more >
GUI and Headless Browser Testing - Travis CI Docs
To run tests requiring a graphical user interface on Travis CI, use xvfb (X Virtual Framebuffer) to imitate a display. If you need...
Read more >
selenium tests fail: xvfb-run: error: Xvfb failed to start
Below code to start XVFB server and test in headless mode written for java perspective. should run below command in CENTOS.
Read more >
100909 - Xvfb crashes on bots when running aura_unittests ...
Issue 100909: Xvfb crashes on bots when running aura_unittests and views_unittests ... [==========] Running 35 tests from 5 test cases. [----------] Global test...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found