unittest 测试可以用 python <test_file_path> 的方式直接运行并且返回结果,但是 pytest 的测试文件则不行,必须使用 pytest命令。
为什么不能直接用 python 执行呢?
猜测是 pytest 的测试文件,需要经过处理之后才能够变成真正的 python 代码,所以不能直接交给解释器,是这样吗?是否有更多细节?
补充:
- 去谷歌上搜索
pytest test script run by Python command没有看到更多信息。 - 当然,使用
pytest包在 python 脚本中运行测试也行,但这也并不是直接运行。