python-pytest-cases icon indicating copy to clipboard operation
python-pytest-cases copied to clipboard

Provide a parameter to guarantee fixture uniqueness in `@fixture`

Open smarie opened this issue 6 years ago • 1 comments
trafficstars

session-scoped fixtures are not guaranteed to be unique by session, and module-scoped fixtures are not guaranteed to be unique for an unique parameter, in pytest. See pytest-dev/pytest#2846

We could at least try to provide a workaround in the @cases_fixture decorator, such as ensure_unique=True.

Note that https://github.com/pytest-dev/pytest/issues/3393 will not solve the problem because if users have two parametrized session-scoped fixtures, one of them will end-up being setup/teardown twice for each of its parameters.

smarie avatar Dec 21 '18 09:12 smarie

Updated this issue since @cases_fixture is now deprecated and equivalent to @fixture + @parametrize_with_cases

smarie avatar Jan 07 '19 17:01 smarie