A small example package
Project description
pytest-xdist-gnumake
Integration of pytest-xdist with GNU Make job server
Imagine you have a Makefile target that runs pytest in addition to other tests:
test: test-python test-mypy
test-python:
pytest --numprocesses=8 my_app
test-mypy:
mypy my_app
Conveniently, you just have to run make test to run both test
targets. To save time, you can even run make -j8 test (8 being the
number of cpu cores that you have at your disposal in this example) to
run everything in parallel. But what really happens now is that
-
makeknows it has 8 slots available, and starts pytest and mypy in parallel -
mypy runs on one cpu core
-
pytest-xdist starts its own job server with 8 parallel workers
In effect you now are running 9 parallel processes, one more than anticipated. This does not matter too much in this simplified example, but if you have big testsuites then you would like to avoid that.
The solution to this issue is this pytest-xdist plugin, which makes the pytest-xdist workers communicate with the GNU make jobserver to avoid exceeding the total limit.
Installation
Simply pip install pytest-xdist-gnumake, and the plugin should be
picked up automatically by pytest-xdist.
Limitations
Local execution only
The GNU jobserver uses the local file system (a fifo in /tmp), so
this will not work with remote xdist workers.
Needs modern make
Older make versions relied on passing open file descriptors to child process, but pytest-xdist will always close those. You need GNU make >= 4.4 in order for the communication with the jobserver to work, that is, a version of make that uses the fifo jobserver. See https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html for details.
If your make version is too old then the plugin will print:
$ pytest --numprocesses=8 my_app
pytest-xdist-gnumake using dummy job server: no job server found
and tests will run as if the plugin was not installed. Otherwise, it will print:
$ pytest --numprocesses=8 my_app
pytest-xdist-gnumake using gnu make jobserver client
Acknowledgements
- GNU Make https://www.gnu.org/software/make/
- https://pytest.org and https://github.com/pytest-dev/pytest-xdist to parallelize Python testsuites
- https://github.com/milahu/gnumake-tokenpool to communicate with GNU Make
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_xdist_gnumake-1.0.0.tar.gz.
File metadata
- Download URL: pytest_xdist_gnumake-1.0.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d0cffd948c63578c176e5c05b14411aa5eef14c49643b537d0b9ada919f9ae9
|
|
| MD5 |
d408679dbedc7c528805fd421ffab78f
|
|
| BLAKE2b-256 |
d19b61f2c8774fce243f22cd053dd4c30933fbef6e7ddd679cb497d6f1428c2a
|
File details
Details for the file pytest_xdist_gnumake-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pytest_xdist_gnumake-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfa23c9cbcaa01dbc8dc2a42ce3acbb6629a3f302c220a35a2b17bcae53a25eb
|
|
| MD5 |
10aa96480ef6f9dfae4b44ad21f4786a
|
|
| BLAKE2b-256 |
868505ca5865282e2dfac46131c4988044d312e08edfe7e86bc69323a147cd41
|