Test Overview
This test suite shows two independent tests using pytest. Each test checks a simple math operation without relying on the other test's result. This avoids test interdependence, ensuring tests can run in any order and still pass.
This test suite shows two independent tests using pytest. Each test checks a simple math operation without relying on the other test's result. This avoids test interdependence, ensuring tests can run in any order and still pass.
import pytest # Test 1: Check addition def test_addition(): result = 2 + 3 assert result == 5 # Test 2: Check multiplication def test_multiplication(): result = 4 * 5 assert result == 20
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and discovers test_addition | No tests have run yet | - | PASS |
| 2 | test_addition executes: calculates 2 + 3 | Calculation done, result = 5 | Assert result == 5 | PASS |
| 3 | Test runner discovers test_multiplication | test_addition passed, no shared state | - | PASS |
| 4 | test_multiplication executes: calculates 4 * 5 | Calculation done, result = 20 | Assert result == 20 | PASS |