Установка:
pip install pytest
Создание теста:
# test_math.py
def add(a, b):
return a + b
def test_add():
assert add(2, 3) == 5
Запуск: `pytest test_math.py`
pytest найдёт функции с префиксом `test_` и выполнит их, проверяя утверждения.
CO CodeShadow @codeshadowcources · 77 subscribers
pip install pytest
# test_math.py
def add(a, b):
return a + b
def test_add():
assert add(2, 3) == 5