[Checkins] SVN: zope.testrunner/trunk/ Work around sporadic failures in the subprocess buffering tests.

Tres Seaver tseaver at palladion.com
Tue Oct 25 16:58:04 UTC 2011


Log message for revision 123154:
  Work around sporadic failures in the subprocess buffering tests. 
  
  If the test takes too long to run, some assertions fail because they
  expect some lines to be output very fast, while some a bit slower. If
  the machine is a bit loaded when the text is executed, all the lines
  take a long time to be displayed, which causes spurious errors.
  
  The fix is trivial: it consists of ignoring the additional lines using
  doctest's ellipsis.
  
  Unfortunately, the ellipsis is sometimes not flexible enough (you can't
  start a result block with '...' and the test fails if you use the
  ellipsis to omit in a place where there's nothing to omit), so you have
  to play a bit around those limitations to have a stable test.
  
  Thanks to Jonathan Ballet for the patch!
  

Changed:
  U   zope.testrunner/trunk/CHANGES.txt
  U   zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-buff.txt

-=-
Modified: zope.testrunner/trunk/CHANGES.txt
===================================================================
--- zope.testrunner/trunk/CHANGES.txt	2011-10-24 22:41:46 UTC (rev 123153)
+++ zope.testrunner/trunk/CHANGES.txt	2011-10-25 16:58:03 UTC (rev 123154)
@@ -4,7 +4,8 @@
 4.0.4 (unreleased)
 ==================
 
-- Nothing changed yet.
+- Work around sporadic timing-related issues in the subprocess buffering
+  tests.  Thanks to Jonathan Ballet for the patch!
 
 
 4.0.3 (2011-03-17)

Modified: zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-buff.txt
===================================================================
--- zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-buff.txt	2011-10-24 22:41:46 UTC (rev 123153)
+++ zope.testrunner/trunk/src/zope/testrunner/testrunner-layers-buff.txt	2011-10-25 16:58:03 UTC (rev 123154)
@@ -65,15 +65,19 @@
 second.  Before the change that this test verifies, there was a single pause of
 more than a second after the second suite ran.
 
-    >>> pause = datetime.timedelta(seconds=0.3)
-    >>> last_line, last_time = record.pop(0)
-    >>> for line, time in record:
-    ...     if time-last_time >= pause:
-    ...         # We paused!
-    ...         print 'PAUSE FOUND BETWEEN THESE LINES:'
-    ...         print ''.join([last_line, line, '-'*70])
-    ...     last_line, last_time = line, time
-    ... # doctest: +ELLIPSIS
+    >>> def assert_progressive_output():
+    ...     pause = datetime.timedelta(seconds=0.3)
+    ...     last_line, last_time = record.pop(0)
+    ...     print '---'
+    ...     for line, time in record:
+    ...         if time-last_time >= pause:
+    ...             # We paused!
+    ...             print 'PAUSE FOUND BETWEEN THESE LINES:'
+    ...             print ''.join([last_line, line, '-'*70])
+    ...         last_line, last_time = line, time
+
+    >>> assert_progressive_output() # doctest: +ELLIPSIS
+    ---...
     PAUSE FOUND BETWEEN THESE LINES:...
       Running:
      test_something (sampletests_buffering.TestSomething2)
@@ -81,7 +85,7 @@
     PAUSE FOUND BETWEEN THESE LINES:
      test_something (sampletests_buffering.TestSomething2)
      test_something2 (sampletests_buffering.TestSomething2)
-    ----------------------------------------------------------------------
+    ---...
 
 Because this is a test based on timing, it may be somewhat fragile.  However,
 on a relatively slow machine, this timing works out fine; I'm hopeful that this
@@ -127,14 +131,19 @@
 automated agent. In particular for the second point, notice below that, as
 before, the progress output is not buffered.
 
-    >>> last_line, last_time = record.pop(0)
-    >>> for line, time in record:
-    ...     if time-last_time >= pause:
-    ...         # We paused!
-    ...         print 'PAUSE FOUND BETWEEN THIS OUTPUT:'
-    ...         print '\n'.join([last_line, line, '-'*70])
-    ...     last_line, last_time = line, time
-    ... # doctest: +ELLIPSIS
+    >>> def assert_progressive_output():
+    ...     pause = datetime.timedelta(seconds=0.3)
+    ...     last_line, last_time = record.pop(0)
+    ...     print '---'
+    ...     for line, time in record:
+    ...         if time-last_time >= pause:
+    ...             # We paused!
+    ...             print 'PAUSE FOUND BETWEEN THIS OUTPUT:'
+    ...             print '\n'.join([last_line, line, '-'*70])
+    ...         last_line, last_time = line, time
+
+    >>> assert_progressive_output() # doctest: +ELLIPSIS
+    ---...
     PAUSE FOUND BETWEEN THIS OUTPUT:...
     .
     .
@@ -142,7 +151,7 @@
     PAUSE FOUND BETWEEN THIS OUTPUT:
     .
      LAYER FINISHED
-    ----------------------------------------------------------------------
+    ---...
 
 
 Fake an IOError reading the output of the subprocess to exercise the



More information about the checkins mailing list