Test Overview
This test checks that pytest distributes test cases evenly across multiple workers when using the pytest-xdist plugin. It verifies that each worker runs a subset of tests and all tests complete successfully.
This test checks that pytest distributes test cases evenly across multiple workers when using the pytest-xdist plugin. It verifies that each worker runs a subset of tests and all tests complete successfully.
import pytest @pytest.mark.parametrize('num', range(6)) def test_sample(num): assert num >= 0 # Run command: pytest -n 3 # This runs tests distributed across 3 workers
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test run starts with pytest-xdist plugin enabled using 3 workers | Terminal shows pytest starting with 3 parallel workers | - | PASS |
| 2 | Pytest collects 6 test cases from test_sample function | Test collection complete, 6 tests found | Verify total tests collected equals 6 | PASS |
| 3 | Tests are distributed evenly across 3 workers (2 tests per worker) | Each worker assigned 2 tests to run | Check that each worker runs exactly 2 tests | PASS |
| 4 | Each worker executes its assigned tests in parallel | Workers running tests concurrently | Each test assertion (num >= 0) passes | PASS |
| 5 | All workers complete tests and report results | Terminal shows all 6 tests passed | Verify all tests passed with no failures | PASS |