python-pytest-cases
python-pytest-cases copied to clipboard
Provide a parameter to guarantee fixture uniqueness in `@fixture`
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.
Updated this issue since @cases_fixture is now deprecated and equivalent to @fixture + @parametrize_with_cases