summaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-02-12 16:07:05 +0300
committerrobot-piglet <[email protected]>2026-02-12 16:45:04 +0300
commit8a3744491c12d828238bc749cb292b813d6b6240 (patch)
tree7f710761f5f2fcd5e808ac2144694673d2acaddd /contrib/python/hypothesis
parent286b6e0d3e4bb8953b980a186898ca5f3e2b3d90 (diff)
Intermediate changes
commit_hash:e663c7dce2db288250c956133b4fb5d2cd5e7198
Diffstat (limited to 'contrib/python/hypothesis')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py40
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
4 files changed, 34 insertions, 12 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index fefdd240c7d..495e87a7de0 100644
--- a/contrib/python/hypothesis/py3/.dist-info/METADATA
+++ b/contrib/python/hypothesis/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: hypothesis
-Version: 6.151.2
+Version: 6.151.3
Summary: The property-based testing library for Python
Author-email: "David R. MacIver and Zac Hatfield-Dodds" <[email protected]>
License-Expression: MPL-2.0
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
index 22a0e7ec8f7..8892254e25b 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
@@ -154,11 +154,30 @@ class HealthCheckState:
return "\n".join(out)
+# Stop when 99% confident the true valid rate is below 1%.
+# For k valid examples, we need n invalid such that:
+# P(seeing <= k valid in n+k trials | rate=1%) <= 1%
+# k=0: (0.99)^n <= 0.01 -> n >= ln(0.01)/ln(0.99)
+# Each additional valid example adds ~ln(0.01)/ln(0.99)/3 to threshold.
+def _calculate_thresholds(
+ confidence: float = 0.99, min_valid_rate: float = 0.01
+) -> tuple[int, int]:
+ log_confidence = math.log(1 - confidence)
+ log_invalid_rate = math.log(1 - min_valid_rate)
+ base = math.ceil(log_confidence / log_invalid_rate)
+ # Approximate increase per valid example (from binomial CDF)
+ per_valid = math.ceil(base / 3)
+ return base, per_valid
+
+
+INVALID_THRESHOLD_BASE, INVALID_PER_VALID = _calculate_thresholds()
+
+
class ExitReason(Enum):
max_examples = "settings.max_examples={s.max_examples}"
max_iterations = (
"settings.max_examples={s.max_examples}, "
- "but < 10% of examples satisfied assumptions"
+ "but < 1% of examples satisfied assumptions"
)
max_shrinks = f"shrunk example {MAX_SHRINKS} times"
finished = "nothing left to do"
@@ -724,12 +743,11 @@ class ConjectureRunner:
# while in the other case below we just want to move on to shrinking.)
if self.valid_examples >= self.settings.max_examples:
self.exit_with(ExitReason.max_examples)
- if self.call_count >= max(
- self.settings.max_examples * 10,
- # We have a high-ish default max iterations, so that tests
- # don't become flaky when max_examples is too low.
- 1000,
- ):
+ # Stop when we're 99% confident the true valid rate is below 1%.
+ invalid_threshold = (
+ INVALID_THRESHOLD_BASE + INVALID_PER_VALID * self.valid_examples
+ )
+ if (self.invalid_examples + self.overrun_examples) > invalid_threshold:
self.exit_with(ExitReason.max_iterations)
if self.__tree_is_exhausted():
@@ -1088,8 +1106,12 @@ class ConjectureRunner:
# but with the important distinction that this clause will move on to
# the shrinking phase having found one or more bugs, while the other
# will exit having found zero bugs.
- if self.valid_examples >= self.settings.max_examples or self.call_count >= max(
- self.settings.max_examples * 10, 1000
+ invalid_threshold = (
+ INVALID_THRESHOLD_BASE + INVALID_PER_VALID * self.valid_examples
+ )
+ if (
+ self.valid_examples >= self.settings.max_examples
+ or (self.invalid_examples + self.overrun_examples) > invalid_threshold
): # pragma: no cover
return False
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index a6c6132bb7b..2a6cae682d8 100644
--- a/contrib/python/hypothesis/py3/hypothesis/version.py
+++ b/contrib/python/hypothesis/py3/hypothesis/version.py
@@ -8,5 +8,5 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
-__version_info__ = (6, 151, 2)
+__version_info__ = (6, 151, 3)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 422507d0d73..da69508f495 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.151.2)
+VERSION(6.151.3)
LICENSE(MPL-2.0)