test: test cases for catching exeptions

This commit is contained in:
Sandro Zimmermann 2026-03-27 16:30:11 +01:00
parent e4a038edaf
commit b5472e9716

View File

@ -0,0 +1,24 @@
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"])