Testing demo: pytest using classes


pip install pytest


examples/testing-demo/test_with_pytest_class.py

import mymath

class TestMath():
    def test_math(self):
        assert mymath.add(2, 2) == 4
============================= test session starts ==============================
platform linux -- Python 3.8.2, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /home/gabor/work/slides/python/examples/testing-demo
plugins: flake8-1.0.6
collected 1 item

test_with_pytest_class.py .                                              [100%]

============================== 1 passed in 0.01s ===============================

$ pytest test_with_pytest_class.py
$ echo $?
0

> pytest test_with_pytest_class.py
> echo %ERRORLEVEL%
0