# ValueError: duplicate test IDs: 'test_case_0'

- **ID:** `python/pytest-parametrize-ids-duplicate`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

When using pytest.mark.parametrize with ids parameter, duplicate ID strings cause an error because test IDs must be unique within a parametrized test.

## Version Compatibility

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

## Workarounds

1. **Ensure all IDs in the ids list are unique** (95% success)
   ```
   @pytest.mark.parametrize('x', [1, 2, 3], ids=['case_1', 'case_2', 'case_3'])
def test_example(x):
    ...
Each ID must be different.
   ```
2. **Use a function to generate unique IDs based on the parameter values** (90% success)
   ```
   def id_func(val):
    return f'x={val}'
@pytest.mark.parametrize('x', [1, 2, 3], ids=id_func)
def test_example(x):
    ...
This ensures uniqueness.
   ```

## Dead Ends

- **Removing the ids parameter entirely** — This loses descriptive test names, making test output harder to read. (40% fail)
- **Using a lambda function that returns a constant string** — This will still produce duplicate IDs if the lambda ignores input. (70% fail)
