Skip to content

API Reference

This documentation is automatically generated from the source code docstrings, ensuring it always matches the actual implementation.

Public API

weight

weight

weight(value: int)

Decorator to set the weight of a test for load testing.

Parameters:

Name Type Description Default
value int

The weight of the test (higher = more likely to be selected)

required
Example

@weight(5) def test_important(): pass

Or use pytest marker directly:

@pytest.mark.weight(5) def test_important(): pass

stop_load_testing

stop_load_testing

stop_load_testing(request: FixtureRequest, message: str = 'Test requested stop')

Function to stop the load testing scheduler gracefully.

This sets session.shouldstop to signal pytest to stop the test session without marking the current test as failed. This is the preferred way to stop load testing when a condition is met.

Parameters:

Name Type Description Default
request FixtureRequest

The pytest request fixture (required)

required
message str

The reason for stopping the load testing

'Test requested stop'
Example

from pytest_xdist_load_testing import stop_load_testing

def test_something(request): if some_condition: stop_load_testing(request, "Stopping due to condition")