[Checkins] SVN: megrok.five/trunk/src/megrok/five/tests/test_container.py put the doctest into a module-level docstring, like we typically do in

Philipp von Weitershausen philikon at philikon.de
Thu Feb 15 10:14:50 EST 2007


Log message for revision 72600:
  put the doctest into a module-level docstring, like we typically do in
  grok tests.
  

Changed:
  U   megrok.five/trunk/src/megrok/five/tests/test_container.py

-=-
Modified: megrok.five/trunk/src/megrok/five/tests/test_container.py
===================================================================
--- megrok.five/trunk/src/megrok/five/tests/test_container.py	2007-02-15 15:08:35 UTC (rev 72599)
+++ megrok.five/trunk/src/megrok/five/tests/test_container.py	2007-02-15 15:14:50 UTC (rev 72600)
@@ -1,65 +1,63 @@
-import unittest
-from zope.testing.doctest import DocTestSuite
+"""
+Let's make a container and add a few items.  As you can see, we can
+use the regular IContainer API (Python's mapping API):
 
-def test_container():
-    """
-    Let's make a container and add a few items.  As you can see, we
-    can use the regular IContainer API (Python's mapping API):
+  >>> from megrok.five import Container, Model
+  >>> folder = Container()
+  >>> folder['garfield'] = Model('garfield')
+  >>> folder['john'] = Model('john')
+  >>> folder['odie'] = Model('odie')
 
-      >>> from megrok.five import Container, Model
-      >>> folder = Container()
-      >>> folder['garfield'] = Model('garfield')
-      >>> folder['john'] = Model('john')
-      >>> folder['odie'] = Model('odie')
+The rest of the mapping API is also supported:
 
-    The rest of the mapping API is also supported:
+  >>> sorted(folder)  # test __iter__
+  ['garfield', 'john', 'odie']
 
-      >>> sorted(folder)  # test __iter__
-      ['garfield', 'john', 'odie']
+  >>> sorted(folder.keys())
+  ['garfield', 'john', 'odie']
 
-      >>> sorted(folder.keys())
-      ['garfield', 'john', 'odie']
+  >>> sorted(model.getId() for model in folder.values())
+  ['garfield', 'john', 'odie']
 
-      >>> sorted(model.getId() for model in folder.values())
-      ['garfield', 'john', 'odie']
+  >>> sorted((name, model.getId()) for name, model in folder.items()) # doctest: +NORMALIZE_WHITESPACE
+  [('garfield', 'garfield'),
+   ('john', 'john'),
+   ('odie', 'odie')]
 
-      >>> sorted((name, model.getId()) for name, model in folder.items()) # doctest: +NORMALIZE_WHITESPACE
-      [('garfield', 'garfield'),
-       ('john', 'john'),
-       ('odie', 'odie')]
+  >>> 'garfield' in folder  # test __contains__
+  True
 
-      >>> 'garfield' in folder  # test __contains__
-      True
+  >>> len(folder)  # test __len__
+  3
 
-      >>> len(folder)  # test __len__
-      3
+  >>> folder.get('garfield') == folder['garfield']
+  True
+  >>> folder.get('not-there') is None
+  True
+  >>> folder.get('not-there', 'then take me')
+  'then take me'
 
-      >>> folder.get('garfield') == folder['garfield']
-      True
-      >>> folder.get('not-there') is None
-      True
-      >>> folder.get('not-there', 'then take me')
-      'then take me'
+  >>> del folder['odie']  # test __delitem__
+  >>> len(folder)
+  2
+  >>> sorted(folder)
+  ['garfield', 'john']
 
-      >>> del folder['odie']  # test __delitem__
-      >>> len(folder)
-      2
-      >>> sorted(folder)
-      ['garfield', 'john']
+To maintain compatibility with Zope 2, a container is also an object
+manager:
 
-    To maintain compatibility with Zope 2, a container is also an
-    object manager:
+  >>> folder.garfield.getId()
+  'garfield'
+  >>> sorted(folder.objectIds())
+  ['garfield', 'john']
 
-      >>> folder.garfield.getId()
-      'garfield'
-      >>> sorted(folder.objectIds())
-      ['garfield', 'john']
+etc... (no point here to further dive into the horrors of the object
+manager API.)
+"""
 
-    etc... (no point here to further dive into the horrors of the
-    object manager API.)
+import unittest
+from zope.testing.doctest import DocTestSuite
 
-    """
-
 def test_suite():
     return unittest.TestSuite([
         DocTestSuite(),       



More information about the Checkins mailing list