PPE2/tests/testing/test_catching_exceptions.py

26 lines
695 B
Python

import pytest
from testing.catching_exeptions import double_integers
@pytest.mark.parametrize(
"data, expected_error",
[
(123, "data must be a list"),
([1, "2", 3, 4, 5], "data may contain only integers"),
],
)
def test_double_integers_unhappy_path(data, expected_error) -> None:
with pytest.raises(TypeError, match=expected_error):
double_integers(data)
@pytest.mark.parametrize(
"data, expected_result",
[
([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]),
([0, -1, -2, -3, -4, -5], [0, -2, -4, -6, -8, -10]),
],
)
def test_double_integers_happy_path(data, expected_result) -> None:
assert double_integers(data) == expected_result