Search code examples
pythonpygtkxvfbtox

Running Xvfb from tox


I have some code that uses gtk so unless there is an active DISPLAY, the code raises an RuntimeError: could not open display… This happens when I run tox.

Is there a way to run a Xvfb server from within tox?

I did try adding

/usr/bin/Xvfb :99 -screen 0 1280x1024x24 &

to the commands section but got an InvocationError due to the &. Without it, the command never returns and thus blocks.


Solution

  • Use xvfb-run like so:

    xvfb-run tox -v --recreate
    

    This is easily done in Jenkins Pipefiles…