Skip to content

Commit 391282e

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

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy