A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests.
Project description
A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests.
Installation
You can install “pytest-xvfb” via pip from PyPI:
$ pip install pytest-xvfb
Usage
With Xvfb and the plugin installed, your testsuite automatically runs with Xvfb. This allows tests to be run without windows popping up during GUI tests or on systems without a display (like a CI).
The plugin sees Xvfb being installed as “optional”, since the tests can still run without it installed. If it’s unavailable, it will show an informational message, if on Linux and a DISPLAY is available. When using --xvfb-backend xvfb, this message will turn into a hard error instead.
If you’re currently using xvfb-run in something like a GitHub Actions YAML file simply remove the wrapper and install this plugin instead - then you’ll also have the benefits of Xvfb locally.
Features
You can pass --no-xvfb to explicitly turn off Xvfb (e.g. to visually inspect a failure).
With --xvfb-backend xephyr or --xvfb-backend xvnc, you can use Xephyr or Xvnc in place of Xvfb, e.g. to visually inspect failures.
NOTE: Support for xvnc is currently experimental and not tested on CI, due to incompatibilities with PyVirtualDisplay and Ubuntu 22.04’s tightvncserver.
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.
backend: Either None (Xvfb), "xvfb", "xephyr", or "xvnc".
In a pytest.ini, xvfb_width, xvfb_height, xvfb_colordepth and xvfb_args can be used to configure the respective values. In addition, xvfb_xauth can be set to true to generate an Xauthority token.
Contributing
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.
License
Distributed under the terms of the MIT license, “pytest-xvfb” is free and open source software
Thanks
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.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-xvfb-3.0.0.tar.gz
.
File metadata
- Download URL: pytest-xvfb-3.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3746ab1f4d1159f03f751638d053689ccd284291b38b8fb03d3ebbe7bf69cfc0 |
|
MD5 | cd099c0154e395dc9a48bede2061e90e |
|
BLAKE2b-256 | 373b323923d97a3a53d8f302b8115e6c58f3606f8d2a376d36fec821351bc678 |
File details
Details for the file pytest_xvfb-3.0.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_xvfb-3.0.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 352f247c788457ccdfcfeec8a47a2a6594c8eaf22f0302dae9e2635bb23975c2 |
|
MD5 | df4c4b903911326616acbde8721bb1d5 |
|
BLAKE2b-256 | 8695d1f71d55425daa5f7f534b58ad15efbe1969ad67894033df58dd285eed62 |