How do you parameterize a test in pytest?


Pytest tip:

You can parametrize your tests with @pytest.mark.parametrize.

Example:

import pytest


def is_palindrome(text):
    return text == "".join(reversed(text))


@pytest.mark.parametrize(
    "text, is_pal",
    [
        ("kayak", True),
        ("racecar", True),
        ("bmw", False),
        ("songs", False),
    ],
)
def test_is_palindrome(text, is_pal):
    assert is_palindrome(text) == is_pal