pyo3-pytests: cover more tests on PyPy

This commit is contained in:
David Hewitt 2021-07-18 19:30:30 +01:00
parent 5f2627aac2
commit 95cb5c6ef1
2 changed files with 10 additions and 12 deletions

View File

@ -3,22 +3,23 @@ import platform
import sys
import pytest
from pyo3_pytests.objstore import ObjStore
PYPY = platform.python_implementation() == "PyPy"
@pytest.mark.skipif(PYPY, reason="PyPy does not have sys.getrefcount")
def test_objstore_doesnot_leak_memory():
N = 10000
message = b'\\(-"-;) Praying that memory leak would not happen..'
before = sys.getrefcount(message)
# PyPy does not have sys.getrefcount, provide a no-op lambda and don't
# check refcount on PyPy
getrefcount = getattr(sys, "getrefcount", lambda obj: 0)
before = getrefcount(message)
store = ObjStore()
for _ in range(N):
store.push(message)
del store
gc.collect()
after = sys.getrefcount(message)
after = getrefcount(message)
assert after - before == 0

View File

@ -2,8 +2,6 @@ import platform
from pyo3_pytests.subclassing import Subclassable
PYPY = platform.python_implementation() == "PyPy"
class SomeSubClass(Subclassable):
def __str__(self):
@ -11,7 +9,6 @@ class SomeSubClass(Subclassable):
def test_subclassing():
if not PYPY:
a = SomeSubClass()
assert str(a) == "SomeSubclass"
assert type(a) is SomeSubClass
a = SomeSubClass()
assert str(a) == "SomeSubclass"
assert type(a) is SomeSubClass