Day 8: Pytest Parametrize

Parametrize makes for a whole lot less unit testing code.

Three test cases in just a few lines:

@pytest.mark.parametrize(
    "start_text,shift_amount,expected",
    [("abc", 1, "bcd"), ("abc", 26, "abc"), ("xyz", 3, "abc"), ("xyz", 26, "xyz")],
)
def test_encode(caesar, start_text, shift_amount, expected):
    assert caesar.encode(start_text, shift_amount) == expected


all tags