Pytest override fixture scope

有些话、适合烂在心里 提交于 2021-02-10 05:35:11

问题


I pytest, we declare the fixture scope (function, module, class, session) at the fixture definition. Is it possible to override that scope at the usage of it in a test? So that I can have a default function-scope fixture, but some tests which are using it use it as module-scope?

My concrete scenario is that I'm using parametrized tests, but I want my fixture to be used once over all parameters. Otherwise, the fixture is good to have function scope for all other tests.

来源:https://stackoverflow.com/questions/65722634/pytest-override-fixture-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!