A pytest-xdist scheduler for running specific tests on dedicated workers.
- Improves test runtime by assigning slow tests to separate workers
- Includes custom reporting in
conftest.pyto show test scheduling details
pip install xdist-scheduling-exclusive pytest-xdistTo integrate with your pytest setup, update conftest.py as follows:
from xdist_scheduling_exclusive import ExclusiveLoadScopeScheduling
def pytest_xdist_make_scheduler(config, log):
"""xdist-pytest hook to set scheduler."""
return ExclusiveLoadScopeScheduling(config, log)Create an exclusive tests file exclusive_tests.txt in tests/resources/.
You can identify slow tests using pytest's
--durations
option which sorts tests by execution time.
Remember to remove execution times from the file - it should contain only test node IDs.
See the example in this project's tests/resources/exclusive_tests.txt.
Placing the slowest tests in exclusive_tests.txt will give you the most benefit.
ExclusiveLoadScheduling: Schedules tests fromexclusive_tests.txtfirst on dedicated nodes.ExclusiveLoadFileScheduling: Places tests fromexclusive_tests.txtinto unique scopes. Other tests are grouped as in--dist loadfile: tests from the same file run on the same node.ExclusiveLoadScopeScheduling: Schedules tests fromexclusive_tests.txtfirst on dedicated nodes. Other tests are grouped as in--dist loadscope: tests from the same file run on the same node.
Activate the development environment:
. ./activate.shTo see how tests were scheduled:
python -m pytest -n 4 --xdist-report -sView available scripts:
make help