Pytest override fixture scope

  pytest, python-3.x

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.

Source: Python-3x Questions

LEAVE A COMMENT