Skip to content

Commit

Permalink
Merge pull request #3616 from Zac-HD/inquisitor-setup
Browse files Browse the repository at this point in the history
Separable parts of Inquisitor
  • Loading branch information
Zac-HD authored Apr 19, 2023
2 parents 0966b62 + 31e0d25 commit f93e4d5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 21 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch fixes some documentation and prepares for future features.
4 changes: 2 additions & 2 deletions hypothesis-python/docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Controlling what runs
Hypothesis divides tests into logically distinct phases:

1. Running explicit examples :ref:`provided with the @example decorator <providing-explicit-examples>`.
2. Rerunning a selection of previously failing examples to reproduce a previously seen error
2. Rerunning a selection of previously failing examples to reproduce a previously seen error.
3. Generating new examples.
4. Mutating examples for :ref:`targeted property-based testing <targeted-search>`.
4. Mutating examples for :ref:`targeted property-based testing <targeted-search>` (requires generate phase).
5. Attempting to shrink an example found in previous phases (other than phase 1 - explicit examples cannot be shrunk).
This turns potentially large and complicated examples which may be hard to read into smaller and simpler ones.
6. Attempting to explain the cause of the failure, by identifying suspicious lines of code
Expand Down
5 changes: 1 addition & 4 deletions hypothesis-python/src/hypothesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import zlib
from collections import defaultdict
from functools import partial
from io import StringIO
from random import Random
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -793,9 +792,7 @@ def run(data):
text_repr = repr_call(test, args, kwargs)

if print_example or current_verbosity() >= Verbosity.verbose:
output = StringIO()

printer = RepresentationPrinter(output, context=context)
printer = RepresentationPrinter(context=context)
if print_example:
printer.text("Falsifying example:")
else:
Expand Down
11 changes: 7 additions & 4 deletions hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# obtain one at https://mozilla.org/MPL/2.0/.

from collections import defaultdict
from typing import Dict
from typing import TYPE_CHECKING, Dict

import attr

Expand All @@ -19,7 +19,7 @@
prefix_selection_order,
random_selection_order,
)
from hypothesis.internal.conjecture.data import ConjectureResult, Status
from hypothesis.internal.conjecture.data import ConjectureData, ConjectureResult, Status
from hypothesis.internal.conjecture.floats import (
DRAW_FLOAT_LABEL,
float_to_lex,
Expand All @@ -33,6 +33,9 @@
from hypothesis.internal.conjecture.shrinking import Float, Integer, Lexical, Ordering
from hypothesis.internal.conjecture.shrinking.learned_dfas import SHRINKING_DFAS

if TYPE_CHECKING:
from hypothesis.internal.conjecture.engine import ConjectureRunner


def sort_key(buffer):
"""Returns a sort key such that "simpler" buffers are smaller than
Expand Down Expand Up @@ -268,7 +271,7 @@ def __init__(self, engine, initial, predicate, allow_transition):
takes ConjectureData objects.
"""
assert predicate is not None or allow_transition is not None
self.engine = engine
self.engine: "ConjectureRunner" = engine
self.__predicate = predicate or (lambda data: True)
self.__allow_transition = allow_transition or (lambda source, destination: True)
self.__derived_values = {}
Expand All @@ -278,7 +281,7 @@ def __init__(self, engine, initial, predicate, allow_transition):

# We keep track of the current best example on the shrink_target
# attribute.
self.shrink_target = initial
self.shrink_target: ConjectureData = initial
self.clear_change_tracking()
self.shrinks = 0

Expand Down
8 changes: 8 additions & 0 deletions hypothesis-python/tests/cover/test_database_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,11 @@ def values_agree(self, k):


TestGADReads = GitHubArtifactMocks.TestCase


def test_gadb_coverage():
# Ensure that we always cover the nonempty-archive case, which can otherwise
# cause rare incomplete-coverage failures.
state = GitHubArtifactMocks()
state.save(b"key", b"value")
state.values_agree(b"key")
2 changes: 1 addition & 1 deletion requirements/coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
async-timeout==4.0.2
# via redis
attrs==22.2.0
attrs==23.1.0
# via hypothesis (hypothesis-python/setup.py)
black==23.3.0
# via -r requirements/coverage.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# ./build.sh upgrade-requirements
#
attrs==22.2.0
attrs==23.1.0
# via hypothesis (hypothesis-python/setup.py)
exceptiongroup==1.1.1 ; python_version < "3.11"
# via
Expand Down
18 changes: 9 additions & 9 deletions requirements/tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ astor==0.8.1
# via flake8-simplify
asttokens==2.2.1
# via stack-data
attrs==22.2.0
attrs==23.1.0
# via
# flake8-bugbear
# hypothesis (hypothesis-python/setup.py)
autoflake==2.0.2
autoflake==2.1.1
# via shed
babel==2.12.1
# via sphinx
Expand Down Expand Up @@ -79,7 +79,7 @@ exceptiongroup==1.1.1 ; python_version < "3.11"
# pytest
executing==1.2.0
# via stack-data
filelock==3.11.0
filelock==3.12.0
# via
# tox
# virtualenv
Expand Down Expand Up @@ -134,7 +134,7 @@ idna==3.4
# via requests
imagesize==1.4.1
# via sphinx
importlib-metadata==6.4.1
importlib-metadata==6.5.0
# via
# keyring
# twine
Expand Down Expand Up @@ -230,7 +230,7 @@ pyflakes==3.0.1
# via
# autoflake
# flake8
pygments==2.15.0
pygments==2.15.1
# via
# ipython
# readme-renderer
Expand Down Expand Up @@ -287,7 +287,7 @@ snowballstemmer==2.2.0
# sphinx
sortedcontainers==2.4.0
# via hypothesis (hypothesis-python/setup.py)
soupsieve==2.4
soupsieve==2.4.1
# via beautifulsoup4
sphinx==6.1.3
# via
Expand All @@ -296,7 +296,7 @@ sphinx==6.1.3
# sphinx-hoverxref
# sphinx-rtd-theme
# sphinxcontrib-jquery
sphinx-codeautolink==0.14.1
sphinx-codeautolink==0.15.0
# via -r requirements/tools.in
sphinx-hoverxref==1.3.0
# via -r requirements/tools.in
Expand All @@ -320,7 +320,7 @@ sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
sqlparse==0.4.3
sqlparse==0.4.4
# via django
stack-data==0.6.2
# via ipython
Expand Down Expand Up @@ -370,7 +370,7 @@ urllib3==1.26.15
# via
# requests
# twine
virtualenv==20.21.0
virtualenv==20.21.1
# via tox
wcwidth==0.2.6
# via prompt-toolkit
Expand Down

0 comments on commit f93e4d5

Please sign in to comment.