[Zope-Checkins] SVN: Zope/trunk/lib/python/ExtensionClass/tests.py
Added basic cyclic GC test. Note that this test would fail in
Jim Fulton
jim at zope.com
Thu May 5 06:09:20 EDT 2005
Log message for revision 30246:
Added basic cyclic GC test. Note that this test would fail in
Zope 2.7 and earlier.
Changed:
U Zope/trunk/lib/python/ExtensionClass/tests.py
-=-
Modified: Zope/trunk/lib/python/ExtensionClass/tests.py
===================================================================
--- Zope/trunk/lib/python/ExtensionClass/tests.py 2005-05-05 09:50:09 UTC (rev 30245)
+++ Zope/trunk/lib/python/ExtensionClass/tests.py 2005-05-05 10:09:20 UTC (rev 30246)
@@ -807,6 +807,34 @@
"""
+def test_Basic_gc():
+ """Test to make sure that EC instances participate in GC
+
+ >>> from ExtensionClass import Base
+ >>> import gc
+ >>> class C1(Base):
+ ... pass
+ ...
+ >>> class C2(Base):
+ ... def __del__(self):
+ ... print 'removed'
+ ...
+ >>> a=C1()
+ >>> a.b = C1()
+ >>> a.b.a = a
+ >>> a.b.c = C2()
+ >>> thresholds = gc.get_threshold()
+ >>> gc.set_threshold(0)
+ >>> ignore = gc.collect()
+ >>> del a
+ >>> ignored = gc.collect()
+ removed
+ >>> ignored > 0
+ True
+ >>> gc.set_threshold(*thresholds)
+
+"""
+
from zope.testing.doctest import DocTestSuite
import unittest
More information about the Zope-Checkins
mailing list