/
glukhov2008
/
Python
Обзор
Документация
Войти
/
glukhov2008
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
test_arithmetic_operation.py
20 строк
755 B
AndrewGluss
test func arithmetic_operation() with pytest
11 авг 2022, 17:04
11 авг 2022, 17:04
5a3d5b7
Код
Авторство
О чём код?
from arithmetic_operation import arithmetic_operation import pytest @pytest.mark.parametrize("a,b,expected_result", [(10,5,15)]) def test_arithmetic_add(a,b,expected_result): add = arithmetic_operation("+") assert add(a,b) == expected_result @pytest.mark.parametrize("a,b,expected_result", [(10,5,2)]) def test_arithmetic_div(a,b,expected_result): div = arithmetic_operation("/") assert div(a,b) == expected_result @pytest.mark.parametrize("expected_exception, divider", [(ZeroDivisionError, 0), (TypeError, '2')]) def test_arithmetic_zero(expected_exception, divider): with pytest.raises(expected_exception): div = arithmetic_operation("/") div(10, divider)