aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-10-20 14:47:20 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-10-20 14:56:35 +0300
commit694f58a5c020bfe1028af0fd2d4947d07e2a7080 (patch)
tree21056aeb36965746f3086d630c88f10b3818a247
parentfc579f3c2745a07ecf94b8730df21fb04dbd062d (diff)
downloadydb-694f58a5c020bfe1028af0fd2d4947d07e2a7080.tar.gz
Intermediate changes
commit_hash:15bc9967e5232ba2f5c2b66acdb48018622376b4
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/stateful.py65
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
4 files changed, 36 insertions, 39 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 3de6c50f33..a0ba8f627f 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.112.2
+Version: 6.112.3
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
@@ -41,7 +41,7 @@ Requires-Dist: exceptiongroup>=1.0.0; python_version < "3.11"
Provides-Extra: all
Requires-Dist: black>=19.10b0; extra == "all"
Requires-Dist: click>=7.0; extra == "all"
-Requires-Dist: crosshair-tool>=0.0.72; extra == "all"
+Requires-Dist: crosshair-tool>=0.0.73; extra == "all"
Requires-Dist: django>=3.2; extra == "all"
Requires-Dist: dpcontracts>=0.4; extra == "all"
Requires-Dist: hypothesis-crosshair>=0.0.14; extra == "all"
@@ -64,7 +64,7 @@ Provides-Extra: codemods
Requires-Dist: libcst>=0.3.16; extra == "codemods"
Provides-Extra: crosshair
Requires-Dist: hypothesis-crosshair>=0.0.14; extra == "crosshair"
-Requires-Dist: crosshair-tool>=0.0.72; extra == "crosshair"
+Requires-Dist: crosshair-tool>=0.0.73; extra == "crosshair"
Provides-Extra: dateutil
Requires-Dist: python-dateutil>=1.4; extra == "dateutil"
Provides-Extra: django
diff --git a/contrib/python/hypothesis/py3/hypothesis/stateful.py b/contrib/python/hypothesis/py3/hypothesis/stateful.py
index 067d9c77c6..711762d252 100644
--- a/contrib/python/hypothesis/py3/hypothesis/stateful.py
+++ b/contrib/python/hypothesis/py3/hypothesis/stateful.py
@@ -196,6 +196,10 @@ def run_state_machine_as_test(state_machine_factory, *, settings=None, _min_step
for k, v in list(data.items()):
if isinstance(v, VarReference):
data[k] = machine.names_to_values[v.name]
+ elif isinstance(v, list) and all(
+ isinstance(item, VarReference) for item in v
+ ):
+ data[k] = [machine.names_to_values[item.name] for item in v]
label = f"execute:rule:{rule.function.__name__}"
start = perf_counter()
@@ -300,6 +304,10 @@ class RuleBasedStateMachine(metaclass=StateMachineMeta):
def _pretty_print(self, value):
if isinstance(value, VarReference):
return value.name
+ elif isinstance(value, list) and all(
+ isinstance(item, VarReference) for item in value
+ ):
+ return "[" + ", ".join([item.name for item in value]) + "]"
self.__stream.seek(0)
self.__stream.truncate(0)
self.__printer.output_width = 0
@@ -457,11 +465,8 @@ class Rule:
self.arguments_strategies = {}
bundles = []
for k, v in sorted(self.arguments.items()):
- assert not isinstance(v, BundleReferenceStrategy)
if isinstance(v, Bundle):
bundles.append(v)
- consume = isinstance(v, BundleConsumer)
- v = BundleReferenceStrategy(v.name, consume=consume)
self.arguments_strategies[k] = v
self.bundles = tuple(bundles)
@@ -474,26 +479,6 @@ class Rule:
self_strategy = st.runner()
-class BundleReferenceStrategy(SearchStrategy):
- def __init__(self, name: str, *, consume: bool = False):
- self.name = name
- self.consume = consume
-
- def do_draw(self, data):
- machine = data.draw(self_strategy)
- bundle = machine.bundle(self.name)
- if not bundle:
- data.mark_invalid(f"Cannot draw from empty bundle {self.name!r}")
- # Shrink towards the right rather than the left. This makes it easier
- # to delete data generated earlier, as when the error is towards the
- # end there can be a lot of hard to remove padding.
- position = data.draw_integer(0, len(bundle) - 1, shrink_towards=len(bundle))
- if self.consume:
- return bundle.pop(position) # pragma: no cover # coverage is flaky here
- else:
- return bundle[position]
-
-
class Bundle(SearchStrategy[Ex]):
"""A collection of values for use in stateful testing.
@@ -518,15 +503,29 @@ class Bundle(SearchStrategy[Ex]):
def __init__(self, name: str, *, consume: bool = False) -> None:
self.name = name
- self.__reference_strategy = BundleReferenceStrategy(name, consume=consume)
+ self.consume = consume
def do_draw(self, data):
machine = data.draw(self_strategy)
- reference = data.draw(self.__reference_strategy)
- return machine.names_to_values[reference.name]
+
+ bundle = machine.bundle(self.name)
+ if not bundle:
+ data.mark_invalid(f"Cannot draw from empty bundle {self.name!r}")
+ # Shrink towards the right rather than the left. This makes it easier
+ # to delete data generated earlier, as when the error is towards the
+ # end there can be a lot of hard to remove padding.
+ position = data.draw_integer(0, len(bundle) - 1, shrink_towards=len(bundle))
+ if self.consume:
+ reference = bundle.pop(
+ position
+ ) # pragma: no cover # coverage is flaky here
+ else:
+ reference = bundle[position]
+
+ return reference
def __repr__(self):
- consume = self.__reference_strategy.consume
+ consume = self.consume
if consume is False:
return f"Bundle(name={self.name!r})"
return f"Bundle(name={self.name!r}, {consume=})"
@@ -543,11 +542,6 @@ class Bundle(SearchStrategy[Ex]):
return bool(machine.bundle(self.name))
-class BundleConsumer(Bundle[Ex]):
- def __init__(self, bundle: Bundle[Ex]) -> None:
- super().__init__(bundle.name, consume=True)
-
-
def consumes(bundle: Bundle[Ex]) -> SearchStrategy[Ex]:
"""When introducing a rule in a RuleBasedStateMachine, this function can
be used to mark bundles from which each value used in a step with the
@@ -563,7 +557,10 @@ def consumes(bundle: Bundle[Ex]) -> SearchStrategy[Ex]:
"""
if not isinstance(bundle, Bundle):
raise TypeError("Argument to be consumed must be a bundle.")
- return BundleConsumer(bundle)
+ return type(bundle)(
+ name=bundle.name,
+ consume=True,
+ )
@attr.s()
@@ -610,7 +607,7 @@ def _convert_targets(targets, target):
)
raise InvalidArgument(msg % (t, type(t)))
while isinstance(t, Bundle):
- if isinstance(t, BundleConsumer):
+ if t.consume:
note_deprecation(
f"Using consumes({t.name}) doesn't makes sense in this context. "
"This will be an error in a future version of Hypothesis.",
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index d03669dd3f..59f3d40b73 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, 112, 2)
+__version_info__ = (6, 112, 3)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 513d144e16..d735c78f1a 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.112.2)
+VERSION(6.112.3)
LICENSE(MPL-2.0)