blob: 85215493617b55d7c566e68a4a0823a4872b9691 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
--- contrib/python/pytest/py3/_pytest/python.py (index)
+++ contrib/python/pytest/py3/_pytest/python.py (working tree)
@@ -991,7 +991,7 @@ class IdMaker:
The counter suffix is appended only in case a string wouldn't be unique
otherwise.
"""
- resolved_ids = list(self._resolve_ids())
+ resolved_ids = list(self._limit_ids(self._resolve_ids(), limit=500))
# All IDs must be unique!
if len(resolved_ids) != len(set(resolved_ids)):
# Record the number of occurrences of each ID.
@@ -1005,6 +1005,19 @@ class IdMaker:
id_suffixes[id] += 1
return resolved_ids
+ def _limit_ids(self, ids, limit=500):
+ prefix_count = {}
+ limit -= 6
+ assert limit > 0
+
+ for idval in ids:
+ if len(idval) > limit:
+ prefix = idval[:limit]
+ idx = prefix_count.get(prefix, -1) + 1
+ prefix_count[prefix] = idx
+ idval = "{}-{}".format(prefix, idx)
+ yield idval
+
def _resolve_ids(self) -> Iterable[str]:
"""Resolve IDs for all ParameterSets (may contain duplicates)."""
for idx, parameterset in enumerate(self.parametersets):
|