Skip to main content

A pytest plugin to run Xvfb for tests.

Project description

See Build Status on Travis CI See Build Status on AppVeyor

A pytest plugin to run Xvfb for tests.


You can install “pytest-xvfb” via pip from PyPI:

$ pip install pytest-xvfb


This plugin runs your testsuite with Xvfb to avoid popping up windows during GUI tests or allow them to run on systems without a display (like a CI).

If Xvfb is not installed, it does nothing so your tests will still work.

If you’re currently using xvfb-run in something like .travis.yml, simply remove it and install this plugin instead - then you’ll also have the benefits of Xvfb locally.


You can pass --no-xvfb to explicitly turn off Xvfb (e.g. to visually inspect a failure).

You can mark tests with @pytest.mark.no_xvfb to skip them when they’re running with Xvfb.

A xvfb fixture is available with the following attributes:

  • width: The configured width of the screen.

  • height: The configured height of the screen.

  • colordepth: The configured colordepth of the screen.

  • args: The arguments to be passed to Xvfb.

  • display: The display number (as int) which is used.


Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the MIT license, “pytest-xvfb” is free and open source software


This pytest plugin was generated with Cookiecutter along with @hackebrot’s Cookiecutter-pytest-plugin template.

Thanks to @cgoldberg for xvfbwrapper which was the inspiration for this project.


If you encounter any problems, please file an issue along with a detailed description.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-xvfb-0.2.0.tar.gz (4.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page