我如何为此python函数编写测试?

问题描述 投票:0回答:1

如何使用python为此函数编写pytest。它将返回true或false。

def func(one):
    return one == 'first'

def test_func():
    try:
        assert True
    except:
        assert False
python function testing pytest assert
1个回答
1
投票

仅测试输出的真实性?

def test_func():
    assert func("first")
    assert not func("second")
© www.soinside.com 2019 - 2024. All rights reserved.