Pytest

Parametrizing tests with pytest

In pytest we can parametrize in three different ways:

  • pytest.fixture() - allows to parametrize fixture functions
  • @pytest.mark.parametrize - allows to define arguments for a test function or class
  • pytest_generate_tests - allows to define custom parametrization schemes

This article presents a few examples of how to use parametrization in pytest using @pytest.mark.parametrize. The article starts from the basic tests, and end with the usage of ids and indirect.