Skip to content

Commit b9ec430

Browse files
committed
testing pytest with functions
1 parent c44553c commit b9ec430

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

example_4.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def divide(a, b):
77
else:
88
raise AssertionError('STH is wrong')
99

10-
1110
if divide(10, 2) != 15.0:
1211
print('OK')
1312
else:

example_5.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def divide(a, b):
2+
return a / b
3+
4+
5+
if divide(10, 2) != 15.0:
6+
print('OK')
7+
else:
8+
raise AssertionError('STH is wrong')
9+
10+
try:
11+
divide(10, 0)
12+
raise AssertionError('STH is wrong')
13+
except ZeroDivisionError:
14+
print('OK')

test_example_5.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from example_5 import divide
2+
3+
4+
def test_divide_positive_numbers():
5+
assert divide(10, 2) == 5.0

0 commit comments

Comments
 (0)