25 lines
623 B
Python
25 lines
623 B
Python
from src.tutorial.testing.practice.catching_exeptions import double_integers
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("input", "expected"),
|
|
[
|
|
([1, 2, 3], [2, 4, 6]),
|
|
([5], [10]),
|
|
([100, 900, -2], [200, 1800, -4]),
|
|
],
|
|
)
|
|
def test_double_integers(input, expected):
|
|
assert double_integers(input) == expected
|
|
|
|
|
|
def test_argument_is_list():
|
|
with pytest.raises(TypeError, match="data must be a list"):
|
|
double_integers(4)
|
|
|
|
|
|
def test_list_with_integers_only():
|
|
with pytest.raises(TypeError, match="data may contain only integers"):
|
|
double_integers([4, 3, 2, "str"])
|