Parametrize, 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 se…
ReadFixtures & 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 …
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