我们可以使用@pytest.mark.parametrize装饰器为测试函数传递参数。 下面是一个简单的示例,演示了如何使用pytest来编写测试用例并传递参数: importpytestdefadd(x,y):returnx+y@pytest.mark.parametrize("x, y, expected",[(1,2,3),(10,20,30),(-1,1,0),])deftest_add(x,y,expected):assertadd(x,y)=...
打开你的终端或命令行界面,然后输入并运行上一步中构建的 pytest 命令。例如: bash pytest -v -k test_function test_example.py 执行后,pytest 将根据提供的参数运行测试,并在终端中显示结果。 通过以上步骤,你可以灵活地使用 pytest 的命令行参数来定制测试运行的行为。
My application must be launched with the arguments above. from that specific path. The error I am getting is: bwomsm1closed this ascompletedAug 15, 2022 yizhao5mentioned this issueNov 3, 2022 Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment ...
EDIT: I am able to capture the output by using capfd, but pytest also needs to be run with the -s option. I'll look into this further. Member Author mm318 Mar 6, 2020 Done. Member ivanpauno Mar 6, 2020 Thanks for the suggestion. I think this is what @ivanpauno is referrin...