Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on pypy, skip test that depends on gc behaviour #5528

Merged
merged 1 commit into from
Jul 16, 2023
Merged

Conversation

mattip
Copy link
Contributor

@mattip mattip commented Jul 16, 2023

The test added in #5510 does not pass on PyPy. Without adding a gc.collect, the releaseis never called. But even when addinggc.collect() between the deletions, the output is different. With this change:

from cython.parallel cimport prange
 cimport cython
+import gc
 from random import randint, random
 
 include "../buffers/mockbuffers.pxi"
@@ -43,8 +44,11 @@ def refcounting_stress_test(int N):
 
     # make "release" order predictable
     del aview
+    gc.collect()
     del bview
+    gc.collect()
     del cview
+    gc.collect()
 
     return total

I get as output (release c comes before release b)

    acquired a
    acquired b
    acquired c
    released a
    released c
    released b

I don't think there is a way to get doctest to have alternatives based on implementation, so I suggest skipping the test.

@da-woods da-woods added this to the 3.0 milestone Jul 16, 2023
@da-woods da-woods merged commit 0713b78 into cython:master Jul 16, 2023
75 checks passed
@da-woods
Copy link
Contributor

Thanks @mattip

I don't think there is a way to get doctest to have alternatives based on implementation,

What you can do is put in on the global or class docstring (since these are editable easily) rather than a function docstring:

if pypy:
  __doc__ += """
    >>> something
   """
else:
  __doc__ += """
    >>> something_else
    """

I think in this case skipping is the way to go though.

The other option would be to use Doctest.ELLIPSIS - we care that there's three releases, but we don't really care about the order, so we could rephrase the test to just look for that.

@mattip
Copy link
Contributor Author

mattip commented Jul 16, 2023

Thanks. Maybe at some point git blame will bring someone who is trying to unskip PyPy tests to your comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants