Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jobh committed May 31, 2024
1 parent 26fb918 commit 8f389b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 4 additions & 1 deletion hypothesis-python/RELEASE-sample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ which should:
- :func:`package.function` for link to functions, where the link text will
be ``package.function``, or :func:`~package.function` to show ``function``.
- :class:`package.class` for link to classes (abbreviated as above).
- :issue:`issue-number` for referencing issues or :pull:`pr-number` for PRs.
- :issue:`issue-number` for referencing issues.
- Similarly, :pull:`pr-number` can be used for PRs, but it's usually
preferred to refer to version numbers such as :ref:`version 6.98.9 <v6.98.9>,
as they are meaningful to end users.
- :doc:`link text <chapter#anchor>` for documentation references.
- `link text <https://hypothesis.readthedocs.io/en/latest/chapter.html#anchor>`__
is the same link, for general web addresses.
Expand Down
7 changes: 5 additions & 2 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
RELEASE_TYPE: patch

Account for time spent in garbage collection during tests, to avoid
flaky ``DeadlineExceeded`` errors as seen in :issue:`3975`. Also fixes
overcounting of stateful run times resulting from :issue:`3890`.
flaky ``DeadlineExceeded`` errors as seen in :issue:`3975`.

Also fixes overcounting of stateful run times,
a minor observability bug dating to :ref:`version 6.98.9 <v6.98.9>`
(:issue:`3890`).
23 changes: 14 additions & 9 deletions hypothesis-python/tests/nocover/test_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,11 @@ def test_gc_hooks_do_not_cause_unraisable_recursionerror():

# This test is potentially flaky, because the stack usage of a function is not
# constant. Regardless, if the test passes just once that's sufficient proof that
# it's not the GC (or accounting of it) that is at fault.
# it's not the GC (or accounting of it) that is at fault. Note, I haven't actually
# seen it fail/flake, but I believe it could happen in principle.

# The number of cycles sufficient to reliably trigger a GC cycle, experimentally
# found to be a few hundred on CPython. Multiply by 10 for safety margin.
# The number of cycles sufficient to reliably trigger GC, experimentally found
# to be a few hundred on CPython. Multiply by 10 for safety margin.
NUM_CYCLES = 5_000

def probe_depth():
Expand Down Expand Up @@ -251,12 +252,16 @@ def inner_test(_):
max_depth -= 1
else:
break
# Note that PyPy is a bit weird, in that it raises RecursionError at
# (maxdepth - n) for small positive n, but not at exactly (maxdepth).
# In general, it is really finicky to get the details right in this
# test, so be careful.

# Now check that the limit is unchanged with gc enabled
# Note that PyPy is a bit weird, in that it raises RecursionError at
# (maxdepth - n) for small positive n, but not at exactly (maxdepth).
# In general, it is really finicky to get the details right in this
# test, so be careful.

# Now check that the limit is unchanged with gc enabled, and also that
# leaving a few frames for the callbacks does not fail.
if hasattr(gc, "callbacks"): # see comment above
for n in range(1, 4):
gen_cycles_at_depth(max_depth - n, gc_disable=False)
gen_cycles_at_depth(max_depth, gc_disable=False)
with pytest.raises(RecursionError):
gen_cycles_at_depth(max_depth + 1, gc_disable=False)
Expand Down

0 comments on commit 8f389b8

Please sign in to comment.