Python — From Basics to Advanced · Testing with pytest
Parametrize and Mocking
Testing with pytest
Introduction
@pytest.mark.parametrize runs the same test with different inputs — one piece of code, many cases. monkeypatch (built-in) and mock/mocker (from pytest-mock) let you replace dependencies (functions, classes, settings, environment variables) in isolated tests.