[Checkins] SVN: manuel/trunk/ - add an optional parameter that allows a custom TestCase class to be

Benji York benji at zope.com
Fri Jan 29 08:55:00 EST 2010


Log message for revision 108630:
  - add an optional parameter that allows a custom TestCase class to be
    passed to TestSuite() (patch submitted by Bj?\195?\182rn Tillenius)
  

Changed:
  U   manuel/trunk/CHANGES.txt
  U   manuel/trunk/src/index.txt
  U   manuel/trunk/src/manuel/testing.py

-=-
Modified: manuel/trunk/CHANGES.txt
===================================================================
--- manuel/trunk/CHANGES.txt	2010-01-29 13:47:47 UTC (rev 108629)
+++ manuel/trunk/CHANGES.txt	2010-01-29 13:54:59 UTC (rev 108630)
@@ -7,6 +7,8 @@
 - fix a bug that caused Manuel to choke on empty documents (patch submitted by
   Björn Tillenius)
 - add a pointer to Manuel's Subversion repo on the PyPI page
+- add an optional parameter that allows a custom TestCase class to be passed to
+  TestSuite() (patch submitted by Björn Tillenius)
 
 
 1.0.4 (2010-01-06)

Modified: manuel/trunk/src/index.txt
===================================================================
--- manuel/trunk/src/index.txt	2010-01-29 13:47:47 UTC (rev 108629)
+++ manuel/trunk/src/index.txt	2010-01-29 13:54:59 UTC (rev 108630)
@@ -157,6 +157,28 @@
 .. _send me an email: benji+manuel at benjiyork.com
 
 
+Customizing the TestCase class
+------------------------------
+
+Manuel has its own :class:`manuel.testing.TestClass` class that
+:class:`manuel.testing.TestSuite` uses. If you want to customize it, you
+can pass in your own class to `TestSuite`.
+
+.. code-block:: python
+
+     import os.path
+     import manuel.testing
+
+     class StripDirsTestCase(manuel.testing.TestCase):
+         def shortDescription(self):
+             return os.path.basename(str(self))
+     suite = manuel.testing.TestSuite(
+         m, path_to_test, TestCase=StripDirsTestCase)
+
+    >>> list(suite)[0].shortDescription()
+    'bugs.txt'
+
+
 .. reset-globs
 .. _doctest:
 

Modified: manuel/trunk/src/manuel/testing.py
===================================================================
--- manuel/trunk/src/manuel/testing.py	2010-01-29 13:47:47 UTC (rev 108629)
+++ manuel/trunk/src/manuel/testing.py	2010-01-29 13:54:59 UTC (rev 108630)
@@ -122,10 +122,15 @@
 
     `globs`
       A dictionary containing initial global variables for the tests.
+
+    `TestCase`
+      The TestCase class to be used instead of manuel.testing.TestCase.
+
     """
 
     suite = unittest.TestSuite()
     globs = kws.pop('globs', {})
+    TestCase_class = kws.pop('TestCase', TestCase)
 
     # walk up the stack frame to find the module that called this function
     for depth in range(2, 5):
@@ -150,6 +155,6 @@
         document.parse_with(m)
 
         for regions in group_regions_by_test_case(document):
-            suite.addTest(TestCase(m, regions, globs, **kws))
+            suite.addTest(TestCase_class(m, regions, globs, **kws))
 
     return suite



More information about the checkins mailing list