[Zodb-checkins] CVS: Zope3/src/zope/interface -
declarations.py:1.18.4.1
Jim Fulton
jim at zope.com
Sat Jan 31 09:20:07 EST 2004
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv13636/src/zope/interface
Modified Files:
Tag: zope3-zodb3-devel-branch
declarations.py
Log Message:
Added gc.collect calls (and explanation of same) to doctest examples
to prevent spurious errors when tests are run with gc disabled (-g0).
=== Zope3/src/zope/interface/declarations.py 1.18 => 1.18.4.1 ===
--- Zope3/src/zope/interface/declarations.py:1.18 Fri Nov 21 12:11:43 2003
+++ Zope3/src/zope/interface/declarations.py Sat Jan 31 09:20:04 2004
@@ -664,8 +664,22 @@
same declaration. The declarations are cached in an weak value
dictionary.
- >>> import gc
- >>> x = gc.collect()
+ (Note that, in the examples below, we are going to make
+ assertions about the size of the weakvalue dictionary. For the
+ assertions to be meaningful, we need to force garbage
+ collection to make sure garbage objects are, indeed, removed
+ from the system. Depending on how Python is run, we may need to
+ make multiple calls to be sure. We provide a collect function
+ to help with this:
+
+ >>> import gc
+ >>> def collect():
+ ... for i in range(4):
+ ... gc.collect()
+
+ )
+
+ >>> collect()
>>> before = len(InstanceDeclarations)
>>> class C:
@@ -690,12 +704,12 @@
1
>>> del c1
- >>> x = gc.collect()
+ >>> collect()
>>> len(InstanceDeclarations) == before + 1
1
>>> del c2
- >>> x = gc.collect()
+ >>> collect()
>>> len(InstanceDeclarations) == before
1
More information about the Zodb-checkins
mailing list