如何使用pytest制作测试函数

How to make a test function using pytest

我不知道如何制作测试功能。 我有这个功能

import pytest

def added(a, b, c):
    d = b + c
    e = a + c
    f = a + b
    return (d, e, f)

added(4,6,7)

如何为这个函数制作 test_function。

提前感谢您的帮助

试试这个:

def test_added():
    assert added(4, 6, 7) == (13, 11, 10)

然后执行你的测试函数。如果所有测试都是正确的,你应该得到类似的东西:

1 passed in x.xx seconds

查看 docs 以获得更多帮助。