28. Pytest Basics
pytest is a popular testing framework that simplifies writing and running tests.
Example Test
# test_math.py
def add(a, b): return a + b
def test_add():
assert add(2, 3) == 5
Run with:
pytest
Why pytest?
- Simpler syntax than unittest
- Powerful features like fixtures and plugins
Wrap-Up
pytest makes writing and running tests easier with clean syntax.