Skip to content

Refactor tests to use pytest.mark.parametrize

Past due by over 2 years 0% complete

Currently most tests have asserts inside one function like this

def test_is_even():
    assert is_even(2) == True
    assert is_even(3) == False

instead this should be refactored to be

@pytest.mark.parametrize(
    "input, expected",
    [
        (2, True),
        (1, False),
    ],
)
def test_is_even(input, expected):
    assert is_even(input) == expected

Currently most tests have asserts inside one function like this

def test_is_even():
    assert is_even(2) == True
    assert is_even(3) == False

instead this should be refactored to be

@pytest.mark.parametrize(
    "input, expected",
    [
        (2, True),
        (1, False),
    ],
)
def test_is_even(input, expected):
    assert is_even(input) == expected
Loading