Test Overview
This test checks if a simple addition function returns the correct result using PyTest's assert statement. It verifies that the assert keyword can directly check conditions and report test pass or failure.
This test checks if a simple addition function returns the correct result using PyTest's assert statement. It verifies that the assert keyword can directly check conditions and report test pass or failure.
def add(a, b): return a + b def test_add(): result = add(2, 3) assert result == 5, f"Expected 5 but got {result}"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | PyTest test runner initializes | - | PASS |
| 2 | Calls add(2, 3) | Function add executes and returns 5 | - | PASS |
| 3 | Assert checks if result == 5 | result is 5 | assert result == 5 | PASS |
| 4 | Test ends with pass | Test runner records success | - | PASS |