[Checkins] SVN: z3c.testsetup/branches/new_markers/src/z3c/testsetup/README2.txt Update docs.
Uli Fouquet
uli at gnufix.de
Tue Jan 6 21:55:35 EST 2009
Log message for revision 94561:
Update docs.
Changed:
U z3c.testsetup/branches/new_markers/src/z3c/testsetup/README2.txt
-=-
Modified: z3c.testsetup/branches/new_markers/src/z3c/testsetup/README2.txt
===================================================================
--- z3c.testsetup/branches/new_markers/src/z3c/testsetup/README2.txt 2009-01-07 02:34:36 UTC (rev 94560)
+++ z3c.testsetup/branches/new_markers/src/z3c/testsetup/README2.txt 2009-01-07 02:55:35 UTC (rev 94561)
@@ -125,7 +125,55 @@
Of course, there were more tests than only the ones defined in
``doctest01.txt``. Let's have a look at the other stuff.
+Defining doctests in Python modules
+===================================
+The doctest file described above was a pure .txt file. By default
+``z3c.testsetup`` looks for doctests in files with filename extension
+``.txt``, ``.rst`` and ``.py``. This means, that also doctests in
+Python modules are found by default as in the following example::
+
+ >>> print_file(os.path.join(cavepath, 'doctest08.py'))
+ | """
+ | Doctests in a Python module
+ | ===========================
+ |
+ | We can place doctests also in Python modules.
+ |
+ | :doctest:
+ |
+ | Here the Cave class is defined::
+ |
+ | >>> from z3c.testsetup.tests.othercave.doctest08 import Cave
+ | >>> Cave
+ | <class 'z3c.testsetup...doctest08.Cave'>
+ |
+ | """
+ | class Cave(object):
+ | """A Cave.
+ |
+ | A cave has a number::
+ |
+ | >>> hasattr(Cave, 'number')
+ | True
+ |
+ | """
+ | number = None
+ |
+ | def __init__(self, number):
+ | """Create a Cave.
+ |
+ | We have to give a number if we create a cave::
+ |
+ | >>> c = Cave(12)
+ | >>> c.number
+ | 12
+ |
+ | """
+ | self.number = number
+ |
+
+
Setting up a unittest layer
===========================
More information about the Checkins
mailing list