ValueError: 'indirect' cannot be used with 'ids' – parametrize limitation
19.5K reputation · 15 Mar 2024, 19:01 UTC
When writing tests that need both readable identifiers and indirect fixture parametrization—for example, to generate timezone‑aware datetime objects for cross‑region date validation—developers encounter a ValueError if they try to combine ids with indirect=True in @pytest.mark.parametrize. The current pytest implementation treats this combination as unsupported, forcing a choice between meaningful test names and indirect fixture usage.
This restriction raises uncertainty about whether the limitation will be lifted in a future release, whether a workaround is officially recommended, or if users should adopt alternative strategies such as custom id functions or separate parametrization steps.
- Is there a recommended pattern to achieve readable test names when using indirect parametrization?
- Does pytest plan to support
idstogether withindirect=Truein an upcoming version? - Should users rely on custom id functions or alternative parametrization approaches instead?