Test Overview
This test runs multiple simple tests in parallel using pytest-xdist. It verifies that tests execute concurrently and all pass successfully.
This test runs multiple simple tests in parallel using pytest-xdist. It verifies that tests execute concurrently and all pass successfully.
import pytest import time def test_sleep_1(): time.sleep(1) assert True def test_sleep_2(): time.sleep(1) assert True def test_sleep_3(): time.sleep(1) assert True # Run this with: pytest -n 3 test_parallel.py
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts with pytest-xdist using 3 workers | pytest-xdist initializes 3 parallel workers | - | PASS |
| 2 | Worker 1 runs test_sleep_1, sleeps 1 second | test_sleep_1 is executing in worker 1 | - | PASS |
| 3 | Worker 2 runs test_sleep_2, sleeps 1 second | test_sleep_2 is executing in worker 2 | - | PASS |
| 4 | Worker 3 runs test_sleep_3, sleeps 1 second | test_sleep_3 is executing in worker 3 | - | PASS |
| 5 | Each test asserts True after sleep | All tests completed their sleep and assertion | assert True is True for all tests | PASS |
| 6 | pytest-xdist collects results from all workers | Test results aggregated | All tests passed | PASS |