Test Overview
This test checks that a simple function returns the expected result using PyTest. It verifies PyTest's easy syntax and clear assertion style, showing why PyTest is popular for beginners and experts alike.
This test checks that a simple function returns the expected result using PyTest. It verifies PyTest's easy syntax and clear assertion style, showing why PyTest is popular for beginners and experts alike.
import pytest def add(a, b): return a + b def test_add(): result = add(2, 3) assert result == 5
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | PyTest test runner is initialized | - | PASS |
| 2 | PyTest discovers test_add function | Test function is ready to run | - | PASS |
| 3 | test_add calls add(2, 3) | Function add executes and returns 5 | - | PASS |
| 4 | test_add asserts result == 5 | Assertion compares actual result 5 with expected 5 | assert result == 5 | PASS |
| 5 | Test completes successfully | Test report shows 1 test passed | - | PASS |