Skip to content

Commit 391282e

Browse files
committed
pytest add Exception handler
1 parent 5df36f5 commit 391282e

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

test_pytest_exception_handler.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
import sample_func
3+
4+
5+
def test_add():
6+
assert sample_func.add(3, 4) == 7
7+
assert sample_func.add(-1, 4) == 3
8+
assert sample_func.add(0, 4) == 4
9+
10+
11+
def subtract():
12+
assert sample_func.subtract(3, 4) == -1
13+
assert sample_func.subtract(-1, 4) == -5
14+
assert sample_func.subtract(0, 4) == -4
15+
16+
17+
def multiply():
18+
assert sample_func.multiply(3, 4) == 12
19+
assert sample_func.multiply(3, 4) != 11
20+
assert sample_func.multiply(-1, 4) == -4
21+
assert sample_func.multiply(0, 4) == 0
22+
23+
24+
def division():
25+
assert sample_func.multiply(12, 4) == 3
26+
with pytest.raises(ZeroDivisionError):
27+
sample_func.division(2, 0)

0 commit comments

Comments
 (0)