demo@ubuntu:~/SelfStudy/python3/pytest$ cat test_sample.py
#! /usr/bin/env python3
https://docs.pytest.org/en/6.2.x/gett...
def func(x):
return x + 1
def test_answer():
assert func(3) == 5
#assert func(4) == 5
demo@ubuntu:~/SelfStudy/python3/pytest$ pytest --version
pytest 6.2.4
demo@ubuntu:~/SelfStudy/python3/pytest$ ./test_sample.py
demo@ubuntu:~/SelfStudy/python3/pytest$ pytest
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/demo/SelfStudy/python3/pytest
plugins: playwright-0.1.0, base-url-1.4.2
collected 1 item
test_sample.py F [100%]
================================================================================================= FAILURES =================================================================================================
______________________________________________________________________________________________ test_answer _______________________________________________________________________________________________
def test_answer():
assert func(3) == 5
E assert 4 == 5
E + where 4 = func(3)
test_sample.py:8: AssertionError
========================================================================================= short test summary info ==========================================================================================
FAILED test_sample.py::test_answer - assert 4 == 5
============================================================================================ 1 failed in 0.18s =============================================================================================
demo@ubuntu:~/SelfStudy/python3/pytest$ vi test_sample.py
demo@ubuntu:~/SelfStudy/python3/pytest$ pytest
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/demo/SelfStudy/python3/pytest
plugins: playwright-0.1.0, base-url-1.4.2
collected 1 item
test_sample.py . [100%]
============================================================================================ 1 passed in 0.02s =============================================================================================
demo@ubuntu:~/SelfStudy/python3/pytest$