| 1426 | |
| 1427 | |
| 1428 | def idmaker( |
| 1429 | argnames: Iterable[str], |
| 1430 | parametersets: Iterable[ParameterSet], |
| 1431 | idfn: Optional[Callable[[Any], Optional[object]]] = None, |
| 1432 | ids: Optional[List[Union[None, str]]] = None, |
| 1433 | config: Optional[Config] = None, |
| 1434 | nodeid: Optional[str] = None, |
| 1435 | ) -> List[str]: |
| 1436 | resolved_ids = [ |
| 1437 | _idvalset( |
| 1438 | valindex, parameterset, argnames, idfn, ids, config=config, nodeid=nodeid |
| 1439 | ) |
| 1440 | for valindex, parameterset in enumerate(parametersets) |
| 1441 | ] |
| 1442 | |
| 1443 | # All IDs must be unique! |
| 1444 | unique_ids = set(resolved_ids) |
| 1445 | if len(unique_ids) != len(resolved_ids): |
| 1446 | |
| 1447 | # Record the number of occurrences of each test ID. |
| 1448 | test_id_counts = Counter(resolved_ids) |
| 1449 | |
| 1450 | # Map the test ID to its next suffix. |
| 1451 | test_id_suffixes: Dict[str, int] = defaultdict(int) |
| 1452 | |
| 1453 | # Suffix non-unique IDs to make them unique. |
| 1454 | for index, test_id in enumerate(resolved_ids): |
| 1455 | if test_id_counts[test_id] > 1: |
| 1456 | resolved_ids[index] = f"{test_id}{test_id_suffixes[test_id]}" |
| 1457 | test_id_suffixes[test_id] += 1 |
| 1458 | |
| 1459 | return resolved_ids |
| 1460 | |
| 1461 | |
| 1462 | def _pretty_fixture_path(func) -> str: |