Follow the procedure below
--Prepare the source code --Naming rules --Make the method start with "test" --Judge whether the result is OK or NG from the result of the assert conditional expression
pytest01.py
def add(a, b):
return a + b
def sub(a, b):
return a - b
test_pytest01.py
from pytest01 import add, sub
def test_add():
assert add(1, 2) == 4 #Become NG
def test1_sub():
assert sub(3, 1) == 2 #Become OK
def atest_sub():
assert sub(3, 1) == 2 #pytest cannot be recognized
--Results of implementation
Recommended Posts