Commit db7e3ebe authored by Jason Madden's avatar Jason Madden

Adapt the garbage collection tests to run under PyPy. This makes the overall...

Adapt the garbage collection tests to run under PyPy. This makes the overall test diff smaller and easier to read.
parent 56a8ece3
...@@ -354,6 +354,10 @@ else: ...@@ -354,6 +354,10 @@ else:
PY3 = False PY3 = False
py_impl = getattr(platform, 'python_implementation', lambda: None) py_impl = getattr(platform, 'python_implementation', lambda: None)
PYPY = py_impl() == 'PyPy' PYPY = py_impl() == 'PyPy'
if not hasattr(gc, 'get_threshold'):
# PyPy
gc.get_threshold = lambda: ()
gc.set_threshold = lambda *x: None
import ExtensionClass import ExtensionClass
import Acquisition import Acquisition
...@@ -1795,10 +1799,10 @@ def showaq(m_self, indent=''): ...@@ -1795,10 +1799,10 @@ def showaq(m_self, indent=''):
rval = rval + indent + id + "\n" rval = rval + indent + id + "\n"
return rval return rval
if hasattr(gc, 'get_threshold'): def test_Basic_gc():
#CPython implementation detail """Test to make sure that EC instances participate in GC.
def test_Basic_gc(): Note that PyPy always reports 0 collected objects even
"""Test to make sure that EC instances participate in GC though we can see its finalizers run.
>>> from ExtensionClass import Base >>> from ExtensionClass import Base
>>> import gc >>> import gc
...@@ -1820,7 +1824,7 @@ if hasattr(gc, 'get_threshold'): ...@@ -1820,7 +1824,7 @@ if hasattr(gc, 'get_threshold'):
... ignore = gc.collect() ... ignore = gc.collect()
... del a ... del a
... removed = gc.collect() ... removed = gc.collect()
... print(removed > 0) ... print(removed > 0 or PYPY)
removed removed
True True
removed removed
...@@ -1829,8 +1833,10 @@ if hasattr(gc, 'get_threshold'): ...@@ -1829,8 +1833,10 @@ if hasattr(gc, 'get_threshold'):
>>> gc.set_threshold(*thresholds) >>> gc.set_threshold(*thresholds)
""" """
def test_Wrapper_gc(): def test_Wrapper_gc():
"""Test to make sure that EC instances participate in GC """Test to make sure that EC instances participate in GC.
Note that PyPy always reports 0 collected objects even
though we can see its finalizers run.
>>> import gc >>> import gc
>>> thresholds = gc.get_threshold() >>> thresholds = gc.get_threshold()
...@@ -1848,7 +1854,7 @@ if hasattr(gc, 'get_threshold'): ...@@ -1848,7 +1854,7 @@ if hasattr(gc, 'get_threshold'):
... ignored = gc.collect() ... ignored = gc.collect()
... del a ... del a
... removed = gc.collect() ... removed = gc.collect()
... removed > 0 ... removed > 0 or PYPY
removed removed
True True
removed removed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment