diff options
| author | robot-piglet <[email protected]> | 2024-05-19 11:35:22 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2024-05-19 11:44:32 +0300 |
| commit | bb9c10437b76836b45b5a31a3dbcb2c3b206d18f (patch) | |
| tree | ffb379598491b836aed6be405815b3bb536e4c02 /contrib/python/hypothesis | |
| parent | d7ee09f3b10a1132e4abb80d5a279387d124d785 (diff) | |
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis')
6 files changed, 38 insertions, 11 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA index 79347abbf03..784ab51a97e 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.100.2 +Version: 6.100.4 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/coverage.py b/contrib/python/hypothesis/py3/hypothesis/internal/coverage.py index c71ce28642a..57b9f8ed048 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/coverage.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/coverage.py @@ -48,6 +48,7 @@ def pretty_file_name(f): IN_COVERAGE_TESTS = os.getenv("HYPOTHESIS_INTERNAL_COVERAGE") == "true" +description_stack = [] if IN_COVERAGE_TESTS: @@ -64,8 +65,6 @@ if IN_COVERAGE_TESTS: with open(f"branch-check-{os.getpid()}", mode="a", encoding="utf-8") as log: log.write(json.dumps({"name": name, "value": value}) + "\n") - description_stack = [] - @contextmanager def check_block(name, depth): # We add an extra two callers to the stack: One for the contextmanager diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py b/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py index c9ffa6eb2da..b3bb52c67ee 100644 --- a/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py +++ b/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py @@ -27,8 +27,9 @@ from keyword import iskeyword from random import _inst as global_random_instance from tokenize import COMMENT, detect_encoding, generate_tokens, untokenize from types import ModuleType -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING, Any, Callable, MutableMapping from unittest.mock import _patch as PatchType +from weakref import WeakKeyDictionary from hypothesis.errors import HypothesisWarning from hypothesis.internal.compat import PYPY, is_typed_named_tuple @@ -39,6 +40,7 @@ if TYPE_CHECKING: from hypothesis.strategies._internal.strategies import T READTHEDOCS = os.environ.get("READTHEDOCS", None) == "True" +LAMBDA_SOURCE_CACHE: MutableMapping[Callable, str] = WeakKeyDictionary() def is_mock(obj): @@ -303,7 +305,7 @@ SPACE_FOLLOWS_OPEN_BRACKET = re.compile(r"\( ") SPACE_PRECEDES_CLOSE_BRACKET = re.compile(r" \)") -def extract_lambda_source(f): +def _extract_lambda_source(f): """Extracts a single lambda expression from the string source. Returns a string indicating an unknown body if it gets confused in any way. @@ -439,6 +441,17 @@ def extract_lambda_source(f): return source.strip() +def extract_lambda_source(f): + try: + return LAMBDA_SOURCE_CACHE[f] + except KeyError: + pass + + source = _extract_lambda_source(f) + LAMBDA_SOURCE_CACHE[f] = source + return source + + def get_pretty_function_description(f): if isinstance(f, partial): return pretty(f) @@ -492,7 +505,7 @@ def repr_call(f, args, kwargs, *, reorder=True): if repr_len > 30000: warnings.warn( "Generating overly large repr. This is an expensive operation, and with " - f"a length of {repr_len//1000} kB is is unlikely to be useful. Use -Wignore " + f"a length of {repr_len//1000} kB is unlikely to be useful. Use -Wignore " "to ignore the warning, or -Werror to get a traceback.", HypothesisWarning, stacklevel=2, diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py index 83edacbfefd..300a45e59b2 100644 --- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py +++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py @@ -83,6 +83,7 @@ from hypothesis.internal.compat import ( is_typed_named_tuple, ) from hypothesis.internal.conjecture.utils import calc_label_from_cls, check_sample +from hypothesis.internal.coverage import IN_COVERAGE_TESTS, description_stack from hypothesis.internal.entropy import get_seeder_and_restorer from hypothesis.internal.floats import float_of from hypothesis.internal.observability import TESTCASE_CALLBACKS @@ -1757,8 +1758,22 @@ class CompositeStrategy(SearchStrategy): self.args = args self.kwargs = kwargs - def do_draw(self, data): - return self.definition(data.draw, *self.args, **self.kwargs) + if IN_COVERAGE_TESTS: + # We do a bit of a dance here to ensure that whatever 'outer' description + # stack we might have, doesn't affect the validation code internal to the + # strategy we're drawing from. Otherwise, we'd get flaky fails like #3968. + def do_draw(self, data): + prev = description_stack[:] + try: + description_stack.clear() + return self.definition(data.draw, *self.args, **self.kwargs) + finally: + description_stack[:] = prev + + else: # pragma: no cover + + def do_draw(self, data): + return self.definition(data.draw, *self.args, **self.kwargs) def calc_label(self): return calc_label_from_cls(self.definition) @@ -1810,7 +1825,7 @@ def _composite(f): ) if params[0].default is not sig.empty: raise InvalidArgument("A default value for initial argument will never be used") - if not is_first_param_referenced_in_function(f): + if not (f is typing._overload_dummy or is_first_param_referenced_in_function(f)): note_deprecation( "There is no reason to use @st.composite on a function which " "does not call the provided draw() function internally.", diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py index 7d9f42de8e4..05ca2c83b3e 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, 100, 2) +__version_info__ = (6, 100, 4) __version__ = ".".join(map(str, __version_info__)) diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make index 4e4a82e03a8..420b2737332 100644 --- a/contrib/python/hypothesis/py3/ya.make +++ b/contrib/python/hypothesis/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(6.100.2) +VERSION(6.100.4) LICENSE(MPL-2.0) |
