Fixtures & Test Basics Writing Tests # test_calculator.py — pytest auto-discovers test_*.py / *_test.py, functions named test_* def test_addition(): assert 1 + 1 == 2 # plain assert — pytest rewrites it to show a diff on…
ReadParametrize, Mocking & Coverage Parametrize import pytest @pytest.mark.parametrize('a,b,expected', [ (1, 2, 3), (4, 5, 9), (-1, 1, 0), ]) def test_add(a, b, expected): assert a + b == expected # Each tuple becomes a sepa…
ReadSave this stack to your personal DevRecall — add your own notes, track what you're learning, and share what you know with the community.
Get started — free forever