Skip to content

Create pytest fixtures from parameters

Create pytest fixtures from parameters generates a fixture for an unresolved pytest fixture parameter.

How to use it

Place the caret on an unresolved fixture parameter in a test or fixture function, then run BetterPy: Create pytest fixture ....

When it helps

Use this quick fix when writing tests top-down and adding fixture parameters before defining the fixtures they refer to.

Notes

  • BetterPy creates a @pytest.fixture function in the appropriate scope and imports pytest when needed.
  • The feature is gated by the Create pytest fixtures from parameters setting under Settings | BetterPy | Testing (Pytest) | Fixtures.