# IndexError: list index out of range in parametrized test with indirect=True

- **ID:** `python/pytest-parametrize-index-error`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

When using pytest.mark.parametrize with indirect=True, the number of fixture values provided does not match the number of test arguments, causing an index error when accessing the parameter list.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.0.0 | active | — | — |
| 8.0.0 | active | — | — |

## Workarounds

1. **Ensure the number of values in the parametrize list matches the number of fixture arguments** (95% success)
   ```
   If you have two fixtures (fixture1, fixture2) with indirect=True, provide a list of tuples: 
@pytest.mark.parametrize('fixture1,fixture2', [(val1, val2), (val3, val4)], indirect=True)
def test_example(fixture1, fixture2):
    ...
Each tuple must have exactly two elements.
   ```
2. **Use indirect for only specific fixtures by specifying them explicitly** (85% success)
   ```
   @pytest.mark.parametrize('fixture1', [val1, val2], indirect=['fixture1'])
def test_example(fixture1, other_arg):
    ...
This avoids index errors for mixed indirect and direct parameters.
   ```

## Dead Ends

- **Removing indirect=True from the parametrize decorator** — This changes how fixtures are injected, potentially breaking the test logic that depends on indirect fixture configuration. (60% fail)
- **Adding extra dummy values to the parameter list without adjusting fixture definitions** — This may cause fixture resolution failures or incorrect test behavior if the extra values are not handled. (50% fail)
