在 pytest 中指定运行特定文件
在 pytest 中运行特定文件(如 test/test_broker.py)的语法如下:
pytest -m test.test_amqp
这里的 -m 选项用于指定要运行的模块或类。它后面的参数需要遵循模块或类的名称空间格式,例如:
模块: test.test_amqp类: test.test_amqp.testamqp
在本文中,我们希望运行 test/test_broker.py,它对应于模块 test.test_amqp。因此,我们使用 pytest -m test.test_amqp 命令即可在 pytest 中指定运行该文件。
以上就是如何使用 pytest 命令运行特定文件?的详细内容,更多请关注范的资源库其它相关文章!
转载请注明:范的资源库 » 如何使用pytest命令运行特定文件?