[Checkins] SVN: zc.zk/trunk/src/zc/zk/ Documentation.
Jim Fulton
jim at zope.com
Tue Dec 6 17:12:35 UTC 2011
Log message for revision 123598:
Documentation.
Changed:
U zc.zk/trunk/src/zc/zk/README.txt
U zc.zk/trunk/src/zc/zk/testing.py
-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt 2011-12-06 16:54:12 UTC (rev 123597)
+++ zc.zk/trunk/src/zc/zk/README.txt 2011-12-06 17:12:34 UTC (rev 123598)
@@ -558,8 +558,8 @@
It would be bad, in practice, to remove a node that processes are
watching.
-``zc.zk.ZooKeeper``
--------------------
+zc.zk.ZooKeeper
+---------------
``zc.zk.ZooKeeper(connection_string)``
Return a new instance given a ZooKeeper connection string.
@@ -729,6 +729,21 @@
The ``Properties`` instance is returned.
+Testing support
+---------------
+
+The ``zc.zk.testing`` module provides ``setUp`` and ``tearDown``
+functions that can be used to emulate a ZooKeeper server. To find out
+more, use the help function::
+
+ >>> import zc.zk.testing
+ >>> help(zc.zk.testing)
+
+.. -> ignore
+
+ >>> import zc.zk.testing
+
+
Changes
-------
Modified: zc.zk/trunk/src/zc/zk/testing.py
===================================================================
--- zc.zk/trunk/src/zc/zk/testing.py 2011-12-06 16:54:12 UTC (rev 123597)
+++ zc.zk/trunk/src/zc/zk/testing.py 2011-12-06 17:12:34 UTC (rev 123598)
@@ -11,17 +11,44 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""Testing support
+
+This module provides a mock of zookeeper needed to test use of zc.zk.
+It's especially useful for testing packages that build on zc.zk.
+
+It provides setUp and tearDown functions that can be used with
+doctests or with regular ```unittest`` tests.
+"""
import json
import mock
import time
import zc.zk
import zookeeper
+__all__ = ['assert_', 'setUp', 'tearDown']
+
def assert_(cond, mess=''):
+ """A simple assertion function for use in tests.
+ """
if not cond:
print 'assertion failed: ', mess
def setUp(test, tree=None, connection_string='zookeeper.example.com:2181'):
+ """Set up zookeeper emulation.
+
+ The first argument is a test case object (either doctest or unittest).
+
+ You can optionally pass:
+
+ tree
+ An initial ZooKeeper tree expressed as an import string.
+ If not passed, an initial tree will be created with examples
+ used in the zc.zk doctests.
+
+ connection_string
+ The connection string to use for the emulation server. This
+ defaults to 'zookeeper.example.com:2181'.
+ """
if tree:
zk = ZooKeeper(connection_string, Node())
else:
@@ -56,6 +83,10 @@
getattr(test, 'globs', test.__dict__)['zc.zk.testing'] = teardowns
def tearDown(test):
+ """The matching tearDown for setUp.
+
+ The single argument is the test case passed to setUp.
+ """
globs = getattr(test, 'globs', test.__dict__)
for cm in globs['zc.zk.testing']:
cm()
More information about the checkins
mailing list