Test Overview
This test checks that a simple function returns the correct result and uses proper test naming conventions in pytest. It verifies that the test function name starts with test_ so pytest can discover and run it.
This test checks that a simple function returns the correct result and uses proper test naming conventions in pytest. It verifies that the test function name starts with test_ so pytest can discover and run it.
import pytest def add(a, b): return a + b def test_add_two_numbers(): result = add(2, 3) assert result == 5
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and discovers test functions starting with 'test_' | pytest collects test_add_two_numbers from the test file | - | PASS |
| 2 | pytest runs test_add_two_numbers function | Inside test_add_two_numbers, calls add(2, 3) | - | PASS |
| 3 | Assert that result equals 5 | result is 5 from add function | assert result == 5 | PASS |
| 4 | Test completes successfully | pytest reports test_add_two_numbers PASSED | - | PASS |