Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Test len with 1 parameter

We can parametrize the function with the input string, but then we’ll need to have a test function for each length.

import pytest

@pytest.mark.parametrize("text", ["Foo", "Bar", "🐍🐪🦀"])
def test_cases_3(text):
    assert len(text) == 3

@pytest.mark.parametrize("text", ["apple", "banan"])
def test_cases_5(text):
    assert len(text) == 5