Skip to content

Commit aeaafb5

Browse files
authored
Merge pull request #4888 from gpacix/fix-quadratic-statistics
Summarize statistics events in linear time, not quadratic
2 parents 32ebeb2 + f3f4a29 commit aeaafb5

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎AUTHORS.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ their individual contributions.
7676
* `Gary Donovan <https://www.github.com/garyd203>`_
7777
* `Genevieve Mendoza <https://www.github.com/genevieve-me>`_
7878
* `George Macon <https://www.github.com/gmacon>`_
79+
* `George Paci <https://www.github.com/gpacix>`_
7980
* `Glenn Lehman <https://www.github.com/glnnlhmn>`_
8081
* `Graham Williamson <https://github.com/00willo>`_
8182
* `Grant David Bachman <https://github.com/grantbachman>`_ ([email protected])

‎hypothesis/RELEASE.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RELEASE_TYPE: patch
2+
3+
This patch fixes quadratic-time behaviour when summarising the statistics of a test run, which Hypothesis does for every test when running under :pypi:`pytest`. This avoids an apparent hang after the last test case with a high number of test cases (>100k).

‎hypothesis/src/hypothesis/statistics.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11+
import itertools
1112
import math
1213
from collections import Counter
1314
from collections.abc import Iterable
@@ -108,7 +109,7 @@ def describe_statistics(stats_dict: "StatisticsDict") -> str:
108109
prev_failures = d["distinct-failures"]
109110
# Report events during the generate phase, if there were any
110111
if phase == "generate":
111-
events = Counter(sum((t["events"] for t in cases), []))
112+
events = Counter(itertools.chain.from_iterable(t["events"] for t in cases))
112113
if events:
113114
lines.append(" - Events:")
114115
lines += [

0 commit comments

Comments
 (0)