diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-02-14 13:31:06 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-02-14 13:41:14 +0300 |
commit | f712f1ef01ce85418be783606914eb7ccfb51c08 (patch) | |
tree | dc79a330d350106f6e95d014de2c2362eebdd4b9 /contrib | |
parent | dc2f170b5ffa9adec92ab22a0d59e87e9a96a8e1 (diff) | |
download | ydb-f712f1ef01ce85418be783606914eb7ccfb51c08.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib')
7 files changed, 30 insertions, 13 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA index 8338cfd8cc..29c5c3f323 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.97.1 +Version: 6.97.3 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/core.py b/contrib/python/hypothesis/py3/hypothesis/core.py index 17876c3715..601c33e176 100644 --- a/contrib/python/hypothesis/py3/hypothesis/core.py +++ b/contrib/python/hypothesis/py3/hypothesis/core.py @@ -628,7 +628,7 @@ def get_random_for_wrapped_test(test, wrapped_test): return Random(global_force_seed) else: global _hypothesis_global_random - if _hypothesis_global_random is None: + if _hypothesis_global_random is None: # pragma: no cover _hypothesis_global_random = Random() seed = _hypothesis_global_random.getrandbits(128) wrapped_test._hypothesis_internal_use_generated_seed = seed @@ -1054,7 +1054,9 @@ class StateForActualGivenExecution: if TESTCASE_CALLBACKS: if self.failed_normally or self.failed_due_to_deadline: phase = "shrink" - else: + elif runner := getattr(self, "_runner", None): + phase = runner._current_phase + else: # pragma: no cover # in case of messing with internals phase = "unknown" tc = make_testcase( start_timestamp=self._start_timestamp, @@ -1084,7 +1086,7 @@ class StateForActualGivenExecution: else: database_key = None - runner = ConjectureRunner( + runner = self._runner = ConjectureRunner( self._execute_once_for_engine, settings=self.settings, random=self.random, @@ -1510,8 +1512,7 @@ def given( except UnsatisfiedAssumption: raise DidNotReproduce( "The test data failed to satisfy an assumption in the " - "test. Have you added it since this blob was " - "generated?" + "test. Have you added it since this blob was generated?" ) from None # There was no @reproduce_failure, so start by running any explicit diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py index 961774816f..99a170ca64 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/engine.py @@ -129,6 +129,7 @@ class ConjectureRunner: # Global dict of per-phase statistics, and a list of per-call stats # which transfer to the global dict at the end of each phase. + self._current_phase = "(not a phase)" self.statistics = {} self.stats_per_test_case = [] @@ -175,6 +176,7 @@ class ConjectureRunner: self.stats_per_test_case.clear() start_time = time.perf_counter() try: + self._current_phase = phase yield finally: self.statistics[phase + "-phase"] = { @@ -554,7 +556,7 @@ class ConjectureRunner: corpus.extend(extra) for existing in corpus: - data = self.cached_test_function(existing) + data = self.cached_test_function(existing, extend=BUFFER_SIZE) if data.status != Status.INTERESTING: self.settings.database.delete(self.database_key, existing) self.settings.database.delete(self.secondary_key, existing) @@ -569,7 +571,7 @@ class ConjectureRunner: pareto_corpus.sort(key=sort_key) for existing in pareto_corpus: - data = self.cached_test_function(existing) + data = self.cached_test_function(existing, extend=BUFFER_SIZE) if data not in self.pareto_front: self.settings.database.delete(self.pareto_key, existing) if data.status == Status.INTERESTING: @@ -693,6 +695,7 @@ class ConjectureRunner: ran_optimisations = False while self.should_generate_more(): + self._current_phase = "generate" prefix = self.generate_novel_prefix() assert len(prefix) <= BUFFER_SIZE if ( @@ -763,6 +766,7 @@ class ConjectureRunner: and not ran_optimisations ): ran_optimisations = True + self._current_phase = "target" self.optimise_targets() def generate_mutations_from(self, data): @@ -884,7 +888,8 @@ class ConjectureRunner: if any_improvements: continue - self.pareto_optimise() + if self.best_observed_targets: + self.pareto_optimise() if prev_calls == self.call_count: break @@ -902,6 +907,7 @@ class ConjectureRunner: # but if we've been asked to run it but not generation then we have to # run it explciitly on its own here. if Phase.generate not in self.settings.phases: + self._current_phase = "target" self.optimise_targets() with self._log_phase_statistics("shrink"): self.shrink_interesting_examples() @@ -1011,6 +1017,7 @@ class ConjectureRunner: predicate, allow_transition=allow_transition, explain=Phase.explain in self.settings.phases, + in_target_phase=self._current_phase == "target", ) def cached_test_function(self, buffer, *, error_on_discard=False, extend=0): diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py index d82408f97e..146b1b56f4 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py @@ -317,7 +317,7 @@ class ParetoOptimiser: # If ``destination`` dominates ``source`` then ``source`` # must be dominated in the front - either ``destination`` is in # the front, or it was not added to it because it was - # dominated by something in it., + # dominated by something in it. try: self.front.front.remove(source) except ValueError: diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py index f965829759..39a515d296 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py @@ -271,6 +271,7 @@ class Shrinker: *, allow_transition: bool, explain: bool, + in_target_phase: bool = False, ): """Create a shrinker for a particular engine, with a given starting point and predicate. When shrink() is called it will attempt to find an @@ -309,6 +310,14 @@ class Shrinker: # testing and learning purposes. self.extra_dfas: Dict[str, ConcreteDFA] = {} + # Because the shrinker is also used to `pareto_optimise` in the target phase, + # we sometimes want to allow extending buffers instead of aborting at the end. + if in_target_phase: + from hypothesis.internal.conjecture.engine import BUFFER_SIZE + + self.__extend = BUFFER_SIZE + else: + self.__extend = 0 self.should_explain = explain @derived_value # type: ignore @@ -417,7 +426,7 @@ class Shrinker: with status >= INVALID that would result from running this buffer.""" buffer = bytes(buffer) - result = self.engine.cached_test_function(buffer) + result = self.engine.cached_test_function(buffer, extend=self.__extend) self.incorporate_test_data(result) if self.calls - self.calls_at_last_shrink >= self.max_stall: raise StopShrinking diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py index 81c33333c3..00661fde99 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, 97, 1) +__version_info__ = (6, 97, 3) __version__ = ".".join(map(str, __version_info__)) diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make index b2ecf2aa29..38361352c0 100644 --- a/contrib/python/hypothesis/py3/ya.make +++ b/contrib/python/hypothesis/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(6.97.1) +VERSION(6.97.3) LICENSE(MPL-2.0) |