[Checkins] SVN: zope.testrunner/trunk/ Keep unittest.TestCase.shortDescription happy via _testMethodDoc attribute.

Tres Seaver tseaver at palladion.com
Wed Jun 16 10:01:07 EDT 2010


Log message for revision 113540:
  Keep unittest.TestCase.shortDescription happy via  _testMethodDoc attribute.
  
  Fixes LP #221151.
  

Changed:
  U   zope.testrunner/trunk/CHANGES.txt
  U   zope.testrunner/trunk/src/zope/testrunner/find.py

-=-
Modified: zope.testrunner/trunk/CHANGES.txt
===================================================================
--- zope.testrunner/trunk/CHANGES.txt	2010-06-16 13:39:02 UTC (rev 113539)
+++ zope.testrunner/trunk/CHANGES.txt	2010-06-16 14:01:07 UTC (rev 113540)
@@ -4,6 +4,9 @@
 4.0.0b3 (unreleased)
 ====================
 
+- LP #221151: keep ``unittest.TestCase.shortDescription`` happy by supplying
+  a ``_testMethodDoc`` attribute.
+
 - LP #595052: keep the distribution installable under Python 2.4:  its
   distutils appears to munge the empty ``__init__.py`` file in the
   ``foo.bar`` egg used for testing into a directory.

Modified: zope.testrunner/trunk/src/zope/testrunner/find.py
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/find.py	2010-06-16 13:39:02 UTC (rev 113539)
+++ zope.testrunner/trunk/src/zope/testrunner/find.py	2010-06-16 14:01:07 UTC (rev 113540)
@@ -36,9 +36,13 @@
     Normally the StartUpFailure just acts as an empty test suite to satisfy
     the test runner and statistics:
     
-    >>> s = StartUpFailure(options, None, None)
+    >>> s = StartUpFailure(options, 'fauxmodule', None)
+    >>> s
+    <StartUpFailure module=fauxmodule>
     >>> isinstance(s,unittest.TestCase)
     True
+    >>> s.shortDescription()
+    'StartUpFailure: import errors in fauxmodule.'
 
     However, if the post mortem option is enabled:
 
@@ -88,7 +92,7 @@
     <BLANKLINE>
     EndRun raised
 
-    Annoyingly, sometimes StartupFailures occur when postmortem debugging
+    Annoyingly, sometimes StartUpFailures occur when postmortem debugging
     is enabled but no exc_info is passed. In this case, we raise a
     sensible exception rather than letting the debugger barf with an
     AttributeError:
@@ -99,7 +103,11 @@
     ...
     TypeError: If post_mortem is specified, full exc_info must be passed!
     """
+    def _getTestMethodDoc(self):
+        return 'StartUpFailure: import errors in %s.' % self.module
 
+    _testMethodDoc = property(_getTestMethodDoc,)
+
     def __init__(self, options, module, exc_info):
         if options.post_mortem:
             for item in exc_info:



More information about the checkins mailing list