有没有办法获取pytest中某些测试使用的所有灯具名称?

Is there a way to get all fixtures names used by some test in pytest?

有时很难理解为什么要执行一些固定代码,而实际上不应该执行。所以我想打印所有的fixtures名称,这些名称将由pytest进行一些具体测试以进行更详细的分析,pytest中有这样的功能吗?

is there such feature in pytest?

是的。

I'd like to print all fixtures names, which will be resolved for some concrete test by pytest

你可以先看看这些输出:

pytest --fixtures          # show fixtures
pytest --fixtures -v       # show fixtures also with leading _
pytest --fixtures-per-test # show fixtures per test

如果还不够,你还可以看看这些:

pytest --setup-only
pytest --setup-plan