test: test cases for catching exeptions
This commit is contained in:
parent
e4a038edaf
commit
b5472e9716
24
tests/test_tutorial/test_catching_exeptions.py
Normal file
24
tests/test_tutorial/test_catching_exeptions.py
Normal 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"])
|
||||
Loading…
x
Reference in New Issue
Block a user