aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis/py3
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-06-07 08:44:59 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-06-07 08:54:09 +0300
commita7b5aef2daa5510cf5dd2766cb49be4e389b2945 (patch)
tree8719c72b14e6e430af7ffe83e0f21838e5e25a09 /contrib/python/hypothesis/py3
parent60934aa03970b15d67413cc247f0f933969fa1b5 (diff)
downloadydb-a7b5aef2daa5510cf5dd2766cb49be4e389b2945.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis/py3')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py21
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py22
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py3
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py28
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
7 files changed, 43 insertions, 37 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 2fd0b3adc1..fa62bb86a3 100644
--- a/contrib/python/hypothesis/py3/.dist-info/METADATA
+++ b/contrib/python/hypothesis/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: hypothesis
-Version: 6.102.5
+Version: 6.102.6
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
index 6ac7f2a70f..de6372d2fe 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
@@ -136,7 +136,8 @@ IRKWargsType: TypeAlias = Union[
IntegerKWargs, FloatKWargs, StringKWargs, BytesKWargs, BooleanKWargs
]
IRTypeName: TypeAlias = Literal["integer", "string", "boolean", "float", "bytes"]
-InvalidAt: TypeAlias = Tuple[IRTypeName, IRKWargsType]
+# ir_type, kwargs, forced
+InvalidAt: TypeAlias = Tuple[IRTypeName, IRKWargsType, Optional[IRType]]
class ExtraInformation:
@@ -2084,7 +2085,7 @@ class ConjectureData:
)
if self.ir_tree_nodes is not None and observe:
- node = self._pop_ir_tree_node("integer", kwargs)
+ node = self._pop_ir_tree_node("integer", kwargs, forced=forced)
if forced is None:
assert isinstance(node.value, int)
forced = node.value
@@ -2141,7 +2142,7 @@ class ConjectureData:
)
if self.ir_tree_nodes is not None and observe:
- node = self._pop_ir_tree_node("float", kwargs)
+ node = self._pop_ir_tree_node("float", kwargs, forced=forced)
if forced is None:
assert isinstance(node.value, float)
forced = node.value
@@ -2183,7 +2184,7 @@ class ConjectureData:
},
)
if self.ir_tree_nodes is not None and observe:
- node = self._pop_ir_tree_node("string", kwargs)
+ node = self._pop_ir_tree_node("string", kwargs, forced=forced)
if forced is None:
assert isinstance(node.value, str)
forced = node.value
@@ -2219,7 +2220,7 @@ class ConjectureData:
kwargs: BytesKWargs = self._pooled_kwargs("bytes", {"size": size})
if self.ir_tree_nodes is not None and observe:
- node = self._pop_ir_tree_node("bytes", kwargs)
+ node = self._pop_ir_tree_node("bytes", kwargs, forced=forced)
if forced is None:
assert isinstance(node.value, bytes)
forced = node.value
@@ -2261,7 +2262,7 @@ class ConjectureData:
kwargs: BooleanKWargs = self._pooled_kwargs("boolean", {"p": p})
if self.ir_tree_nodes is not None and observe:
- node = self._pop_ir_tree_node("boolean", kwargs)
+ node = self._pop_ir_tree_node("boolean", kwargs, forced=forced)
if forced is None:
assert isinstance(node.value, bool)
forced = node.value
@@ -2302,7 +2303,9 @@ class ConjectureData:
POOLED_KWARGS_CACHE[key] = kwargs
return kwargs
- def _pop_ir_tree_node(self, ir_type: IRTypeName, kwargs: IRKWargsType) -> IRNode:
+ def _pop_ir_tree_node(
+ self, ir_type: IRTypeName, kwargs: IRKWargsType, *, forced: Optional[IRType]
+ ) -> IRNode:
assert self.ir_tree_nodes is not None
if self._node_index == len(self.ir_tree_nodes):
@@ -2321,7 +2324,7 @@ class ConjectureData:
# (in fact, it is possible that giving up early here results in more time
# for useful shrinks to run).
if node.ir_type != ir_type:
- invalid_at = (ir_type, kwargs)
+ invalid_at = (ir_type, kwargs, forced)
self.invalid_at = invalid_at
self.observer.mark_invalid(invalid_at)
self.mark_invalid(f"(internal) want a {ir_type} but have a {node.ir_type}")
@@ -2330,7 +2333,7 @@ class ConjectureData:
# that is allowed by the expected kwargs, then we can coerce this node
# into an aligned one by using its value. It's unclear how useful this is.
if not ir_value_permitted(node.value, node.ir_type, kwargs):
- invalid_at = (ir_type, kwargs)
+ invalid_at = (ir_type, kwargs, forced)
self.invalid_at = invalid_at
self.observer.mark_invalid(invalid_at)
self.mark_invalid(f"(internal) got a {ir_type} but outside the valid range")
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py
index 3a9061ec35..7768d5ec64 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py
@@ -555,16 +555,13 @@ class TreeNode:
p.text(_node_pretty(ir_type, value, kwargs, forced=i in self.forced))
indent += 2
- if isinstance(self.transition, Branch):
+ with p.indent(indent):
if len(self.values) > 0:
p.break_()
- p.pretty(self.transition)
-
- if isinstance(self.transition, (Killed, Conclusion)):
- with p.indent(indent):
- if len(self.values) > 0:
- p.break_()
+ if self.transition is not None:
p.pretty(self.transition)
+ else:
+ p.text("unknown")
class DataTree:
@@ -843,8 +840,8 @@ class DataTree:
tree. This will likely change in future."""
node = self.root
- def draw(ir_type, kwargs, *, forced=None):
- if ir_type == "float" and forced is not None:
+ def draw(ir_type, kwargs, *, forced=None, convert_forced=True):
+ if ir_type == "float" and forced is not None and convert_forced:
forced = int_to_float(forced)
draw_func = getattr(data, f"draw_{ir_type}")
@@ -869,9 +866,9 @@ class DataTree:
data.conclude_test(t.status, t.interesting_origin)
elif node.transition is None:
if node.invalid_at is not None:
- (ir_type, kwargs) = node.invalid_at
+ (ir_type, kwargs, forced) = node.invalid_at
try:
- draw(ir_type, kwargs)
+ draw(ir_type, kwargs, forced=forced, convert_forced=False)
except StopTest:
if data.invalid_at is not None:
raise
@@ -1021,7 +1018,8 @@ class TreeRecordingObserver(DataObserver):
self.draw_value("boolean", value, was_forced=was_forced, kwargs=kwargs)
def mark_invalid(self, invalid_at: InvalidAt) -> None:
- self.__current_node.invalid_at = invalid_at
+ if self.__current_node.transition is None:
+ self.__current_node.invalid_at = invalid_at
def draw_value(
self,
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
index b828fb0998..f25c0833e8 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py
@@ -207,6 +207,7 @@ class ConjectureRunner:
self.shrinks: int = 0
self.finish_shrinking_deadline: Optional[float] = None
self.call_count: int = 0
+ self.misaligned_count: int = 0
self.valid_examples: int = 0
self.random: Random = random or Random(getrandbits(128))
self.database_key: Optional[bytes] = database_key
@@ -418,6 +419,8 @@ class ConjectureRunner:
}
self.stats_per_test_case.append(call_stats)
self._cache(data)
+ if data.invalid_at is not None: # pragma: no branch # coverage bug?
+ self.misaligned_count += 1
self.debug_data(data)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
index a2ca4a7a0e..4e2ca9a49b 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
@@ -306,6 +306,7 @@ class Shrinker:
# it's time to stop shrinking.
self.max_stall = 200
self.initial_calls = self.engine.call_count
+ self.initial_misaligned = self.engine.misaligned_count
self.calls_at_last_shrink = self.initial_calls
self.passes_by_name: Dict[str, ShrinkPass] = {}
@@ -383,6 +384,10 @@ class Shrinker:
test function."""
return self.engine.call_count
+ @property
+ def misaligned(self):
+ return self.engine.misaligned_count
+
def check_calls(self):
if self.calls - self.calls_at_last_shrink >= self.max_stall:
raise StopShrinking
@@ -501,13 +506,14 @@ class Shrinker:
total_deleted = self.initial_size - len(self.shrink_target.buffer)
calls = self.engine.call_count - self.initial_calls
+ misaligned = self.engine.misaligned_count - self.initial_misaligned
self.debug(
"---------------------\n"
"Shrink pass profiling\n"
"---------------------\n\n"
f"Shrinking made a total of {calls} call{s(calls)} of which "
- f"{self.shrinks} shrank. This deleted {total_deleted} bytes out "
+ f"{self.shrinks} shrank and {misaligned} were misaligned. This deleted {total_deleted} bytes out "
f"of {self.initial_size}."
)
for useful in [True, False]:
@@ -527,16 +533,9 @@ class Shrinker:
continue
self.debug(
- " * %s made %d call%s of which "
- "%d shrank, deleting %d byte%s."
- % (
- p.name,
- p.calls,
- s(p.calls),
- p.shrinks,
- p.deletions,
- s(p.deletions),
- )
+ f" * {p.name} made {p.calls} call{s(p.calls)} of which "
+ f"{p.shrinks} shrank and {p.misaligned} were misaligned, "
+ f"deleting {p.deletions} byte{s(p.deletions)}."
)
self.debug("")
self.explain()
@@ -1321,7 +1320,7 @@ class Shrinker:
@defines_shrink_pass()
def lower_blocks_together(self, chooser):
- block = chooser.choose(self.blocks, lambda b: not b.all_zero)
+ block = chooser.choose(self.blocks, lambda b: not b.trivial)
# Choose the next block to be up to eight blocks onwards. We don't
# want to go too far (to avoid quadratic time) but it's worth a
@@ -1330,7 +1329,7 @@ class Shrinker:
next_block = self.blocks[
chooser.choose(
range(block.index + 1, min(len(self.blocks), block.index + 9)),
- lambda j: not self.blocks[j].all_zero,
+ lambda j: not self.blocks[j].trivial,
)
]
@@ -1623,6 +1622,7 @@ class ShrinkPass:
last_prefix = attr.ib(default=())
successes = attr.ib(default=0)
calls = attr.ib(default=0)
+ misaligned = attr.ib(default=0)
shrinks = attr.ib(default=0)
deletions = attr.ib(default=0)
@@ -1633,6 +1633,7 @@ class ShrinkPass:
initial_shrinks = self.shrinker.shrinks
initial_calls = self.shrinker.calls
+ initial_misaligned = self.shrinker.misaligned
size = len(self.shrinker.shrink_target.buffer)
self.shrinker.engine.explain_next_call_as(self.name)
@@ -1648,6 +1649,7 @@ class ShrinkPass:
)
finally:
self.calls += self.shrinker.calls - initial_calls
+ self.misaligned += self.shrinker.misaligned - initial_misaligned
self.shrinks += self.shrinker.shrinks - initial_shrinks
self.deletions += size - len(self.shrinker.shrink_target.buffer)
self.shrinker.engine.clear_call_explanation()
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index 4bc7530118..6b66ca6a37 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, 102, 5)
+__version_info__ = (6, 102, 6)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 7df369619b..57db535574 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.102.5)
+VERSION(6.102.6)
LICENSE(MPL-2.0)