Skip to content

Commit

Permalink
Reduce difficulty of hitting target in that test
Browse files Browse the repository at this point in the history
  • Loading branch information
DRMacIver committed Dec 15, 2019
1 parent 8e9da46 commit c8c5bbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def should_generate_more():
# entering parts of the tree we consider redundant
# and not worth exploring.
error_on_discard=True,
extend=BUFFER_SIZE
extend=BUFFER_SIZE,
)
except ContainsDiscard:
failed_mutations += 1
Expand All @@ -718,7 +718,8 @@ def should_generate_more():
new_data.status >= data.status
and data.buffer != new_data.buffer
and all(
k in new_data.target_observations and new_data.target_observations[k] >= v
k in new_data.target_observations
and new_data.target_observations[k] >= v
for k, v in data.target_observations.items()
)
):
Expand Down
16 changes: 4 additions & 12 deletions hypothesis-python/src/hypothesis/internal/conjecture/optimiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

from __future__ import absolute_import, division, print_function

from hypothesis.internal.conjecture.data import ConjectureData, Status
from hypothesis.internal.conjecture.datatree import PreviouslyUnseenBehaviour
from hypothesis.internal.conjecture.engine import (
BUFFER_SIZE,
NO_SCORE,
)
from hypothesis.internal.conjecture.data import Status
from hypothesis.internal.conjecture.engine import BUFFER_SIZE, NO_SCORE


class Optimiser(object):
Expand Down Expand Up @@ -129,9 +125,7 @@ def do_hill_climbing(self, select_example):
# further.
and self.current_data.status <= Status.VALID
):
if self.attempt_to_improve(
example_index=select_example(self.current_data)
):
if self.attempt_to_improve(example_index=select_example(self.current_data)):
# If we succeeed at improving the score then we no longer have
# any evidence that we're at a local maximum so we reset the
# count.
Expand All @@ -151,9 +145,7 @@ def attempt_to_improve(self, example_index):
prefix_size = ex.start
prefix = data.buffer[:prefix_size]

attempt = self.engine.cached_test_function(
prefix, extend=BUFFER_SIZE,
)
attempt = self.engine.cached_test_function(prefix, extend=BUFFER_SIZE,)

if self.consider_new_test_data(attempt):
return True
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/tests/cover/test_targeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_targeting_increases_max_length():
@given(strat)
def test_with_targeting(ls):
target(float(len(ls)))
assert len(ls) <= 100
assert len(ls) <= 80

with pytest.raises(AssertionError):
test_with_targeting()
Expand Down

0 comments on commit c8c5bbb

Please sign in to comment.