Adding chapter 5 source code

This commit is contained in:
muassif
2021-02-21 21:40:34 +04:00
committed by GitHub
parent e8469ec365
commit e662762d09
24 changed files with 348 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# test_myadd3.py test suite for myadd function
import pytest
from mypytest.src.myadd3 import add
def test_add1():
""" test case to validate two positive numbers"""
assert add(10, 5) == 15
def test_add2():
""" test case to validate two positive numbers"""
assert add(10, -5) == 5, "should be 5"
def test_add3():
""" test case to validate two positive numbers"""
assert add(-10, 5) == -5
def test_add4():
""" test case to validate two positive numbers"""
assert add(-10, -5) == -15
def ttest_typeerror1():
""" test case to check if we can handle non number input"""
with pytest.raises(TypeError):
add('a', 5)
def ttest_typeerror2():
""" test case to check if we can handle non number input"""
with pytest.raises(TypeError, match="only numbers are allowed"):
add('a', 'b')