Test Overview
This test runs multiple simple tests in parallel using pytest-xdist in a Continuous Integration (CI) environment. It verifies that tests execute concurrently and all pass successfully.
This test runs multiple simple tests in parallel using pytest-xdist in a Continuous Integration (CI) environment. It verifies that tests execute concurrently and all pass successfully.
import pytest def test_addition(): assert 1 + 1 == 2 def test_subtraction(): assert 5 - 3 == 2 def test_multiplication(): assert 3 * 4 == 12 def test_division(): assert 10 / 2 == 5 # To run in parallel in CI, use: pytest -n 4
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts with pytest and xdist plugin using '-n 4' to run 4 tests in parallel | CI environment initializes pytest with parallel workers | - | PASS |
| 2 | pytest discovers 4 test functions: test_addition, test_subtraction, test_multiplication, test_division | Test functions are ready to be executed concurrently | - | PASS |
| 3 | Each test runs in parallel worker process: test_addition runs and asserts 1 + 1 == 2 | test_addition executes in worker 1 | assert 1 + 1 == 2 | PASS |
| 4 | test_subtraction runs in parallel worker process and asserts 5 - 3 == 2 | test_subtraction executes in worker 2 | assert 5 - 3 == 2 | PASS |
| 5 | test_multiplication runs in parallel worker process and asserts 3 * 4 == 12 | test_multiplication executes in worker 3 | assert 3 * 4 == 12 | PASS |
| 6 | test_division runs in parallel worker process and asserts 10 / 2 == 5 | test_division executes in worker 4 | assert 10 / 2 == 5 | PASS |
| 7 | pytest collects results from all parallel workers and aggregates test report | CI system receives all test results | All tests passed | PASS |