pytest_test_categories.xdist_compat¶
pytest-xdist compatibility module.
This module provides utilities and hooks for pytest-xdist compatibility. When tests are run in parallel with xdist, each worker process maintains its own plugin state. This module handles aggregating results from workers back to the controller for accurate reporting.
Key concepts: - Controller: The main pytest process that coordinates workers - Workers: Subprocesses (gw0, gw1, etc.) that execute tests - workeroutput: Dict on worker config for passing data to controller
Hooks used: - pytest_sessionfinish (worker): Send stats via workeroutput - pytest_testnodedown (controller): Aggregate stats from workers
Attributes¶
Functions¶
Deserialize distribution counts from worker output. |
|
|
Check if current process is the xdist controller. |
Check if current process is an xdist worker. |
|
|
Merge worker report data into target report. |
|
Serialize TestCounts to a dict for worker output. |
|
Serialize TestSizeReport data for worker output. |
Module Contents¶
- pytest_test_categories.xdist_compat.deserialize_distribution_counts(data)[source]¶
Deserialize distribution counts from worker output.
- pytest_test_categories.xdist_compat.is_xdist_controller(config)[source]¶
Check if current process is the xdist controller.
The controller is the main pytest process when xdist is active. It coordinates workers but does not execute tests itself.
- Parameters:
config (pytest.Config) – The pytest configuration object.
- Returns:
True if this is the xdist controller, False otherwise.
- Return type:
- pytest_test_categories.xdist_compat.is_xdist_worker()[source]¶
Check if current process is an xdist worker.
- Returns:
True if running as an xdist worker, False otherwise.
- Return type:
- pytest_test_categories.xdist_compat.merge_report_data(target, worker_data)[source]¶
Merge worker report data into target report.
This modifies the target report in place, adding all tests from the worker.
- Parameters:
target (pytest_test_categories.reporting.TestSizeReport) – The target report to merge into.
worker_data (dict[str, object]) – Serialized report data from a worker.
- Return type:
None
- pytest_test_categories.xdist_compat.serialize_distribution_counts(counts)[source]¶
Serialize TestCounts to a dict for worker output.
- Parameters:
counts (pytest_test_categories.distribution.stats.TestCounts) – The test counts to serialize.
- Returns:
A dict that can be safely passed through workeroutput.
- Return type:
- pytest_test_categories.xdist_compat.serialize_report_data(report)[source]¶
Serialize TestSizeReport data for worker output.
- Parameters:
report (pytest_test_categories.reporting.TestSizeReport) – The test size report to serialize.
- Returns:
A dict that can be safely passed through workeroutput.
- Return type: