[Zope3-checkins] CVS: Zope3/src/zope/interface -
declarations.py:1.20
Fred L. Drake, Jr.
fred at zope.com
Fri Feb 20 11:56:51 EST 2004
Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv22473/src/zope/interface
Modified Files:
declarations.py
Log Message:
revision 1.18.4.1
date: 2004/01/31 14:20:04; author: jim; state: Exp; lines: +18 -4
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.19 => 1.20 ===
--- Zope3/src/zope/interface/declarations.py:1.19 Wed Jan 21 16:58:47 2004
+++ Zope3/src/zope/interface/declarations.py Fri Feb 20 11:56:50 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 Zope3-Checkins
mailing list