You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixtures in case files can now be automatically imported using the **experimental** @parametrize_with_cases(import_fixtures=True). Fixes#193
Also, Fixed an issue where a case transformed into a fixture, with the same name as the fixture it requires, would lead to a `pytest` fixture recursion.
-`scope`: The scope of the union fixture to create if `fixture_ref`s are found in the argvalues
289
290
291
+
-`import_fixtures`: experimental feature. Turn this to `True` in order to automatically import all fixtures defined in the cases module into the current module.
Cases can use fixtures the same way as [test functions do](https://docs.pytest.org/en/stable/fixture.html#fixtures-as-function-arguments): simply add the fixture names as arguments in their signature and make sure the fixture exists either in the same module, or in a [`conftest.py`](https://docs.pytest.org/en/stable/fixture.html?highlight=conftest.py#conftest-py-sharing-fixture-functions) file in one of the parent packages. See [`pytest` documentation on sharing fixtures](https://docs.pytest.org/en/stable/fixture.html?highlight=conftest.py#conftest-py-sharing-fixture-functions).
373
+
Cases can use fixtures the same way as [test functions do](https://docs.pytest.org/en/stable/fixture.html#fixtures-as-function-arguments): simply add the fixture names as arguments in their signature and make sure the fixture exists or is imported either in the module where `@parametrize_with_cases` is used, or in a [`conftest.py`](https://docs.pytest.org/en/stable/fixture.html?highlight=conftest.py#conftest-py-sharing-fixture-functions) file in one of the parent packages.
374
+
375
+
See [`pytest` documentation on sharing fixtures](https://docs.pytest.org/en/stable/fixture.html?highlight=conftest.py#conftest-py-sharing-fixture-functions)and this [blog](https://gist.github.com/peterhurford/09f7dcda0ab04b95c026c60fa49c2a68).
376
+
377
+
You can use the **experimental**`@parametrize_with_cases(import_fixtures=True)` argument to perform the import automatically for you, see [API reference](./api_reference.md#parametrize_with_cases).
374
378
375
379
!!! warning "Use `@fixture` instead of `@pytest.fixture`"
376
380
If a fixture is used by *some* of your cases only, then you *should* use the `@fixture` decorator from pytest-cases instead of the standard `@pytest.fixture`. Otherwise you fixture will be setup/teardown forall cases even those not requiring it. See [`@fixture` doc](./api_reference.md#fixture).
0 commit comments