我尝试使用以下代码在Python代码中调用pytest。代码运行良好。你知道吗
args = ['test_folder_name', '--junitxml=output.xml', '--ignore=file_to_ignore.py']
ret_code = pytest.main(args)
但是,如果在选项中的文件路径周围添加双引号,则会引发错误:
args = ['test_folder_name', '--junitxml="output.xml"', '--ignore="file_to_ignore.py"']
ret_code = pytest.main(args)
当我在命令行中调用pytest时,我可以将选项指定为--junitxml=“somepath”,这允许somepath包含空格。为什么我打电话时不能做同样的事pytest.main文件在Python代码中?你知道吗
这些报价由shell处理。由于使用
pytest.main
时没有通过shell调用,因此根本不需要它们。你知道吗如果你添加它们,你的输入中会有引号,这会导致错误。你知道吗
这两种方法都可以:
相关问题 更多 >
编程相关推荐