Test Overview
This test runs a simple function test using the pytest command. It verifies that the function returns the expected result.
This test runs a simple function test using the pytest command. It verifies that the function returns the expected result.
import pytest def add(a, b): return a + b def test_add(): assert add(2, 3) == 5
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts and discovers test functions in the file | Terminal shows pytest starting and collecting tests | — | PASS |
| 2 | pytest runs the test_add function | Function add(2, 3) is called and returns 5 | Check if add(2, 3) == 5 | PASS |
| 3 | pytest reports test result | Terminal shows one test passed | Test passed confirmation | PASS |
pytest command do when run in a project folder?pytest without arguments searches for test files and runs all tests found.-v option stands for verbose and shows detailed test results.-d, --detail, and --verbose-output are not valid pytest flags.pytest test_math.py, what will happen?pytest -v test_example.py but get an error: pytest: error: unrecognized arguments: -v. What is the likely cause?-v is unrecognized, which is unusual because -v is a valid pytest option.slow in your project using pytest. Which command correctly runs only those tests?-m option runs tests matching a marker expression, such as slow.--only, --mark, and -s do not filter tests by marker.Pass the test and this pattern moves unknown