Christopher Tyler

Use pytest-xdist to Speed Up Testing

From Andros Fenollosa’s article you can run tests in parallel across multiple CPU cores. For example for one of my projects, I did the following:

1
2
> uv add --dev pytest-xdist
> uv run pytest -n 4

This will run on 4 cores. Use -n auto to run on all available cores. I did not do this due to known memory constraints I have with some of my tests. See [pytest-xdist documentation](pytest-xdist — pytest-xdist documentation) for more information.

<< Previous Post

|

Next Post >>

#Python #Pytest