smarie / python-pytest-cases

Separate test code from test cases in pytest.
https://smarie.github.io/python-pytest-cases/
BSD 3-Clause "New" or "Revised" License
348 stars 40 forks source link

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

Open smarie opened 5 years ago

smarie commented 5 years ago

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 commented 5 years ago

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