[Zope3-checkins] SVN: Zope3/branches/srichter-blow-services/src/zope/ Merge more of Jim's changes.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Dec 17 17:04:26 EST 2004


Log message for revision 28645:
  Merge more of Jim's changes.
  

Changed:
  U   Zope3/branches/srichter-blow-services/src/zope/app/tests/test.py
  U   Zope3/branches/srichter-blow-services/src/zope/testing/doctest.py

-=-
Modified: Zope3/branches/srichter-blow-services/src/zope/app/tests/test.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/tests/test.py	2004-12-17 21:36:22 UTC (rev 28644)
+++ Zope3/branches/srichter-blow-services/src/zope/app/tests/test.py	2004-12-17 22:04:25 UTC (rev 28645)
@@ -369,9 +369,14 @@
                 self._lastWidth = width
             self.stream.flush()
         self._threads = threading.enumerate()
+
         self.__super_startTest(test)
+        # the super version can't count. ;)
+        self.testsRun += test.countTestCases() - 1
+
         self._testtimes[test] = time.time()
 
+
     def getShortDescription(self, test):
         s = self.getDescription(test)
         if len(s) > self._maxWidth:

Modified: Zope3/branches/srichter-blow-services/src/zope/testing/doctest.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/testing/doctest.py	2004-12-17 21:36:22 UTC (rev 28644)
+++ Zope3/branches/srichter-blow-services/src/zope/testing/doctest.py	2004-12-17 22:04:25 UTC (rev 28645)
@@ -2102,7 +2102,24 @@
     _unittest_reportflags = flags
     return old
 
-
+_para_re = re.compile('\s*\n\s*\n\s*')
+def _unittest_count(docstring):
+    words = 0
+    count = 0
+    for p in _para_re.split(docstring):
+        p = p.strip()
+        if not p:
+            continue
+        if p.startswith('>>> '):
+            if words:
+                count += 1
+                words = 0
+        else:
+            words = 1
+            
+    return count or 1
+            
+    
 class DocTestCase(unittest.TestCase):
 
     def __init__(self, test, optionflags=0, setUp=None, tearDown=None,
@@ -2115,6 +2132,11 @@
         self._dt_setUp = setUp
         self._dt_tearDown = tearDown
 
+        self._dt_count = _unittest_count(test.docstring)
+
+    def countTestCases(self):
+        return self._dt_count
+
     def setUp(self):
         test = self._dt_test
 



More information about the Zope3-Checkins mailing list