Skip to content

Commit 88d81c2

Browse files
committed
adjust call_count
1 parent b4114e9 commit 88d81c2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

hypothesis-python/docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def setup(app):
218218
.. |st.data| replace:: :func:`~hypothesis.strategies.data`
219219
.. |st.one_of| replace:: :func:`~hypothesis.strategies.one_of`
220220
.. |st.text| replace:: :func:`~hypothesis.strategies.text`
221+
.. |st.characters| replace:: :func:`~hypothesis.strategies.characters`
221222
.. |st.tuples| replace:: :func:`~hypothesis.strategies.tuples`
222223
.. |st.sets| replace:: :func:`~hypothesis.strategies.sets`
223224
.. |st.dictionaries| replace:: :func:`~hypothesis.strategies.dictionaries`

hypothesis-python/src/hypothesis/internal/conjecture/engine.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,11 @@ def test_function(self, data: ConjectureData) -> None:
488488
self.debug(self.__pending_call_explanation)
489489
self.__pending_call_explanation = None
490490

491-
self.call_count += 1
492-
493491
interrupted = False
494492
try:
495493
self.__stoppable_test_function(data)
496494
except KeyboardInterrupt:
495+
self.call_count += 1
497496
interrupted = True
498497
raise
499498
except BackendCannotProceed as exc:
@@ -508,12 +507,24 @@ def test_function(self, data: ConjectureData) -> None:
508507
and (self.__failed_realize_count / self.call_count) > 0.2
509508
):
510509
self._switch_to_hypothesis_provider = True
510+
511+
assert data.status is Status.VALID
512+
# we do not count BackendCannotProceed which did not make any choices
513+
# against call_count.
514+
# (if it did make choices, then it might have executed the test
515+
# function, so we count it. The important invariant is
516+
# self.call_count == "number of times test_* was called").
517+
if data.length > 0:
518+
self.valid_examples += 1
519+
self.call_count += 1
520+
511521
# skip the post-test-case tracking; we're pretending this never happened
512522
interrupted = True
513523
data.cannot_proceed_scope = exc.scope
514524
data.freeze()
515525
return
516526
except BaseException:
527+
self.call_count += 1
517528
data.freeze()
518529
if self.settings.backend != "hypothesis":
519530
realize_choices(data, for_failure=True)
@@ -542,6 +553,7 @@ def test_function(self, data: ConjectureData) -> None:
542553
if data.misaligned_at is not None: # pragma: no branch # coverage bug?
543554
self.misaligned_count += 1
544555

556+
self.call_count += 1
545557
self.debug_data(data)
546558

547559
if (

0 commit comments

Comments
 (0)