Skip to content

Parametrize pytest test

Parametrize pytest test adds, removes, completes, and maintains pytest.mark.parametrize parameters for pytest tests.

How to use it

Place the caret in a pytest test or parametrize decorator, then run the available BetterPy parametrize intention. Inside a parametrized test's function parameter list, invoke basic completion and select the aggregate suggestion to insert every missing static argname in decorator order.

When it helps

Use this feature when turning a single test into a parametrized test, adding another parameter to an existing decorator, inserting all missing function parameters at once, removing an unused parameter, or renaming parametrized arguments safely.

Notes

  • The feature includes rename validation for parametrized argument names.
  • BetterPy keeps function parameters and decorator argnames synchronized.
  • Completion supports comma-separated strings, tuples of strings, lists of strings, and stacked decorators; dynamic argname expressions are left to normal completion.
  • The feature is gated by the Parametrize pytest test setting under Settings | BetterPy | Testing (Pytest) | Parametrize.