[Checkins]
SVN: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/pythontestsetup.txt
Further docs/tests.
Uli Fouquet
uli at gnufix.de
Wed Feb 13 14:04:54 EST 2008
Log message for revision 83804:
Further docs/tests.
Changed:
U Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/pythontestsetup.txt
-=-
Modified: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/pythontestsetup.txt
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/pythontestsetup.txt 2008-02-13 18:56:52 UTC (rev 83803)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/pythontestsetup.txt 2008-02-13 19:04:54 UTC (rev 83804)
@@ -153,9 +153,10 @@
functions of a ``UnitTestSetup`` instance, or by passing appropriate
values to the constructor. Both methods will be shown below.
-Customizing the module search:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``regexp_list``: customizing the module search:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
The searching for appropriate test modules is basically done by the
two methods ``getModules`` and ``isTestModule``. The latter does
additional checking. Namely it checks for the existance of the above
@@ -240,7 +241,37 @@
['notatest2.py']
+``pfilter_func``: Modifying the filter function
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Another method to change the set of found modules is to pass another
+filter function. By default all modules are taken into account, that
+provide a matching docstring. But you might look for other things in a
+module. That's what the ``pfilter_func`` parameter is for::
+
+ >>> setup.pfilter_func
+ <bound method UnitTestSetup.isTestModule of ...>
+
+As we see, the ``isTestModule`` method is used. You can pass another
+method that takes a module as only parameter and returns ``True`` or
+``False``. Let's create such a function::
+
+ >>> import os
+ >>> def custom_filter(module):
+ ... modfile = os.path.basename(module.__file__)
+ ... if modfile.startswith('notatest'):
+ ... return True
+ ... return False
+
+This functions accepts all modules, whose filename starts with
+'notatest'. Now, we setup a new test setup and see the result::
+
+ >>> custom_setup = UnitTestSetup(cave,
+ ... pfilter_func = custom_filter)
+ >>> suite = custom_setup.getTestSuite()
+ >>> get_basenames_from_suite(suite)
+ ['notatest2.py']
+
If you need more complex checks here, you can derive your customized
test setup class and overwrite ``isModule()``.
More information about the Checkins
mailing list