xdist scheduler to repeately run tests
Project description
pytest-xdist-load-testing
A pytest-xdist scheduler for continuous load testing with weighted test selection
Features
- Continuous Test Execution: Runs tests repeatedly until manually interrupted
- Weighted Test Selection: Control test execution frequency using the
@weightdecorator - Random Selection: Tests are selected randomly based on their weights using
random.choices - Graceful Interruption: Tests and fixtures can stop the scheduler programmatically
- pytest-xdist Integration: Seamlessly integrates with pytest-xdist's distributed testing
Requirements
- Python 3.9+
- pytest >= 8.4.2
- pytest-xdist >= 3.8.0
Installation
pip install pytest-xdist-load-testing
Examples
See the examples/
folder for working examples.
Basic Load Testing
Run your tests with pytest-xdist to enable the load testing scheduler:
pytest --load-test -n 4 path/to/test_module.py # Run with 4 workers
The scheduler will continuously supply tests to workers until interrupted (Ctrl+C).
Important: Load testing requires specifying a single test module. Running multiple modules will result in an error:
pytest --load-test -n 4 tests/ # ERROR: Multiple modules detected
pytest --load-test -n 4 test_a.py test_b.py # ERROR: Multiple modules
This restriction ensures proper fixture handling and test isolation during continuous execution.
Stopping the Scheduler
Tests can stop the scheduler programmatically using the stop_load_testing function:
from pytest_xdist_load_testing import stop_load_testing
def test_with_stop_condition():
result = check_system_health()
if result.critical_failure:
stop_load_testing("Critical failure detected")
Load Test with Weighted Distribution
from pytest_xdist_load_testing import weight
@weight(70)
def test_read_heavy():
"""70% of requests"""
assert api.get("/data").status_code == 200
@weight(20)
def test_write_operations():
"""20% of requests"""
assert api.post("/data", json={}).status_code == 201
@weight(10)
def test_admin_operations():
"""10% of requests"""
assert api.delete("/data/old").status_code == 204
Command Line Options
The plugin adds the following command line option:
--load-test Enable load testing mode with continuous test execution
Rate Limiting and Shared State
For rate limiting and shared state management across pytest-xdist workers, see the companion package pytest-xdist-rate-limit.
Documentation
- API Reference - Complete API documentation
License
Distributed under the terms of the MIT license, "pytest-xdist-load-testing" is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.
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_load_testing-0.2.4.tar.gz.
File metadata
- Download URL: pytest_xdist_load_testing-0.2.4.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80cc294d6c0de502f88cc911860e27adc2148ab771c1cc64056a7bae0cab7fe5
|
|
| MD5 |
15fb830319cd5a7e3b895dc42311de4e
|
|
| BLAKE2b-256 |
f189296b269d4aaddef07dd5732f83f6bba9501d133a205af9c41ff606c49e53
|
Provenance
The following attestation bundles were made for pytest_xdist_load_testing-0.2.4.tar.gz:
Publisher:
release.yml on xverges/pytest-xdist-load-testing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_xdist_load_testing-0.2.4.tar.gz -
Subject digest:
80cc294d6c0de502f88cc911860e27adc2148ab771c1cc64056a7bae0cab7fe5 - Sigstore transparency entry: 715884054
- Sigstore integration time:
-
Permalink:
xverges/pytest-xdist-load-testing@cb6031816f2603724f1de67cbfcfd30298b2a4b5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/xverges
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb6031816f2603724f1de67cbfcfd30298b2a4b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_xdist_load_testing-0.2.4-py3-none-any.whl.
File metadata
- Download URL: pytest_xdist_load_testing-0.2.4-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a40a2e7587f9c939465645b826815ba8b46b50795634bcae3f784c557751b32f
|
|
| MD5 |
1d60b96b638570c6c2a931111ce637da
|
|
| BLAKE2b-256 |
858437d8c2248cec237c124066ba566103438d05fe3b1ab47395b132ff6abd3b
|
Provenance
The following attestation bundles were made for pytest_xdist_load_testing-0.2.4-py3-none-any.whl:
Publisher:
release.yml on xverges/pytest-xdist-load-testing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_xdist_load_testing-0.2.4-py3-none-any.whl -
Subject digest:
a40a2e7587f9c939465645b826815ba8b46b50795634bcae3f784c557751b32f - Sigstore transparency entry: 715884055
- Sigstore integration time:
-
Permalink:
xverges/pytest-xdist-load-testing@cb6031816f2603724f1de67cbfcfd30298b2a4b5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/xverges
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb6031816f2603724f1de67cbfcfd30298b2a4b5 -
Trigger Event:
push
-
Statement type: