[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner Improved the way lines are erased when --progress option is used.

Jim Fulton jim at zope.com
Tue Nov 1 19:15:34 EST 2005


Log message for revision 39838:
  Improved the way lines are erased when --progress option is used.
  

Changed:
  U   zope.testing/trunk/src/zope/testing/testrunner-errors.txt
  U   zope.testing/trunk/src/zope/testing/testrunner-progress.txt
  U   zope.testing/trunk/src/zope/testing/testrunner.py

-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner-errors.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2005-11-01 23:54:35 UTC (rev 39837)
+++ zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2005-11-02 00:15:33 UTC (rev 39838)
@@ -233,9 +233,10 @@
             x = y + 1
         NameError: global name 'y' is not defined
     <BLANKLINE>
-    \r
         2/56 (3.6%)\r
+                   \r
         3/56 (5.4%)\r
+                   \r
         4/56 (7.1%)
     <BLANKLINE>
     Error in test test3 (sample2.sampletests_e.Test)
@@ -248,9 +249,10 @@
         x = y + 1
     NameError: global name 'y' is not defined
     <BLANKLINE>
-    \r
         5/56 (8.9%)\r
+                   \r
         6/56 (10.7%)\r
+                    \r
         7/56 (12.5%)
     <BLANKLINE>
     Failure in test testrunner-ex/sample2/e.txt
@@ -271,7 +273,6 @@
             return x
         NameError: global name 'x' is not defined
     <BLANKLINE>
-    \r
         8/56 (14.3%)
     <BLANKLINE>
     Failure in test test (sample2.sampletests_f.Test)
@@ -282,46 +283,84 @@
         raise self.failureException, \
     AssertionError: 1 != 0
     <BLANKLINE>
-    \r
         9/56 (16.1%)\r
+                    \r
         10/56 (17.9%)\r
+                     \r
         11/56 (19.6%)\r
+                     \r
         12/56 (21.4%)\r
+                     \r
         13/56 (23.2%)\r
+                     \r
         14/56 (25.0%)\r
+                     \r
         15/56 (26.8%)\r
+                     \r
         16/56 (28.6%)\r
+                     \r
         17/56 (30.4%)\r
+                     \r
         18/56 (32.1%)\r
+                     \r
         19/56 (33.9%)\r
+                     \r
         20/56 (35.7%)\r
+                     \r
         24/56 (42.9%)\r
+                     \r
         25/56 (44.6%)\r
+                     \r
         26/56 (46.4%)\r
+                     \r
         27/56 (48.2%)\r
+                     \r
         28/56 (50.0%)\r
+                     \r
         29/56 (51.8%)\r
+                     \r
         30/56 (53.6%)\r
+                     \r
         31/56 (55.4%)\r
+                     \r
         32/56 (57.1%)\r
+                     \r
         33/56 (58.9%)\r
+                     \r
         34/56 (60.7%)\r
+                     \r
         35/56 (62.5%)\r
+                     \r
         36/56 (64.3%)\r
+                     \r
         40/56 (71.4%)\r
+                     \r
         41/56 (73.2%)\r
+                     \r
         42/56 (75.0%)\r
+                     \r
         43/56 (76.8%)\r
+                     \r
         44/56 (78.6%)\r
+                     \r
         45/56 (80.4%)\r
+                     \r
         46/56 (82.1%)\r
+                     \r
         47/56 (83.9%)\r
+                     \r
         48/56 (85.7%)\r
+                     \r
         49/56 (87.5%)\r
+                     \r
         50/56 (89.3%)\r
+                     \r
         51/56 (91.1%)\r
+                     \r
         52/56 (92.9%)\r
+                     \r
         56/56 (100.0%)\r
+                      \r
     <BLANKLINE>
       Ran 56 tests with 3 failures and 1 errors in 0.054 seconds.
     True

Modified: zope.testing/trunk/src/zope/testing/testrunner-progress.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-progress.txt	2005-11-01 23:54:35 UTC (rev 39837)
+++ zope.testing/trunk/src/zope/testing/testrunner-progress.txt	2005-11-02 00:15:33 UTC (rev 39838)
@@ -25,33 +25,59 @@
       Set up samplelayers.Layer122 in 0.000 seconds.
       Running:
         1/34 (2.9%)\r
+                   \r
         2/34 (5.9%)\r
+                   \r
         3/34 (8.8%)\r
+                   \r
         4/34 (11.8%)\r
+                    \r
         5/34 (14.7%)\r
+                    \r
         6/34 (17.6%)\r
+                    \r
         7/34 (20.6%)\r
+                    \r
         8/34 (23.5%)\r
+                    \r
         9/34 (26.5%)\r
+                    \r
         10/34 (29.4%)\r
+                     \r
         11/34 (32.4%)\r
+                     \r
         12/34 (35.3%)\r
+                     \r
         17/34 (50.0%)\r
+                     \r
         18/34 (52.9%)\r
+                     \r
         19/34 (55.9%)\r
+                     \r
         20/34 (58.8%)\r
+                     \r
         21/34 (61.8%)\r
+                     \r
         22/34 (64.7%)\r
+                     \r
         23/34 (67.6%)\r
+                     \r
         24/34 (70.6%)\r
+                     \r
         25/34 (73.5%)\r
+                     \r
         26/34 (76.5%)\r
+                     \r
         27/34 (79.4%)\r
+                     \r
         28/34 (82.4%)\r
+                     \r
         29/34 (85.3%)\r
+                     \r
         34/34 (100.0%)\r
+                      \r
     <BLANKLINE>
-      Ran 34 tests with 0 failures and 0 errors in 0.010 seconds.
+      Ran 34 tests with 0 failures and 0 errors in 0.008 seconds.
     Tearing down left over layers:
       Tear down samplelayers.Layer122 in 0.000 seconds.
       Tear down samplelayers.Layer12 in 0.000 seconds.
@@ -66,7 +92,7 @@
 width, when the terminal width can't be determined, is 80:
 
 >>> sys.argv = 'test --layer 122 -pv'.split()
->>> _ = testrunner.run(defaults)
+>>> testrunner.run(defaults)
 Running tests at level 1
 Running samplelayers.Layer122 tests:
   Set up samplelayers.Layer1 in 0.000 seconds.
@@ -74,36 +100,64 @@
   Set up samplelayers.Layer122 in 0.000 seconds.
   Running:
     1/34 (2.9%) test_x1 (sample1.sampletests.test122.TestA)\r
+                                                           \r
     2/34 (5.9%) test_y0 (sample1.sampletests.test122.TestA)\r
+                                                           \r
     3/34 (8.8%) test_z0 (sample1.sampletests.test122.TestA)\r
+                                                           \r
     4/34 (11.8%) test_x0 (sample1.sampletests.test122.TestB)\r
+                                                            \r
     5/34 (14.7%) test_y1 (sample1.sampletests.test122.TestB)\r
+                                                            \r
     6/34 (17.6%) test_z0 (sample1.sampletests.test122.TestB)\r
+                                                            \r
     7/34 (20.6%) test_1 (sample1.sampletests.test122.TestNotMuch)\r
+                                                                 \r
     8/34 (23.5%) test_2 (sample1.sampletests.test122.TestNotMuch)\r
+                                                                 \r
     9/34 (26.5%) test_3 (sample1.sampletests.test122.TestNotMuch)\r
-    10/34 (29.4%) test_x0 (sample1.sampletests.test122)          \r
+                                                                 \r
+    10/34 (29.4%) test_x0 (sample1.sampletests.test122)\r
+                                                       \r
     11/34 (32.4%) test_y0 (sample1.sampletests.test122)\r
+                                                       \r
     12/34 (35.3%) test_z1 (sample1.sampletests.test122)\r
+                                                       \r
     17/34 (50.0%) ... /testrunner-ex/sample1/sampletests/../../sampletestsl.txt\r
-    18/34 (52.9%) test_x1 (sampletests.test122.TestA)                          \r
+                                                                               \r
+    18/34 (52.9%) test_x1 (sampletests.test122.TestA)\r
+                                                     \r
     19/34 (55.9%) test_y0 (sampletests.test122.TestA)\r
+                                                     \r
     20/34 (58.8%) test_z0 (sampletests.test122.TestA)\r
+                                                     \r
     21/34 (61.8%) test_x0 (sampletests.test122.TestB)\r
+                                                     \r
     22/34 (64.7%) test_y1 (sampletests.test122.TestB)\r
+                                                     \r
     23/34 (67.6%) test_z0 (sampletests.test122.TestB)\r
+                                                     \r
     24/34 (70.6%) test_1 (sampletests.test122.TestNotMuch)\r
+                                                          \r
     25/34 (73.5%) test_2 (sampletests.test122.TestNotMuch)\r
+                                                          \r
     26/34 (76.5%) test_3 (sampletests.test122.TestNotMuch)\r
-    27/34 (79.4%) test_x0 (sampletests.test122)           \r
+                                                          \r
+    27/34 (79.4%) test_x0 (sampletests.test122)\r
+                                               \r
     28/34 (82.4%) test_y0 (sampletests.test122)\r
+                                               \r
     29/34 (85.3%) test_z1 (sampletests.test122)\r
+                                               \r
     34/34 (100.0%) ... pe/testing/testrunner-ex/sampletests/../sampletestsl.txt\r
+                                                                               \r
+<BLANKLINE>
   Ran 34 tests with 0 failures and 0 errors in 0.008 seconds.
 Tearing down left over layers:
   Tear down samplelayers.Layer122 in 0.000 seconds.
   Tear down samplelayers.Layer12 in 0.000 seconds.
   Tear down samplelayers.Layer1 in 0.000 seconds.
+False
 
 The terminal width is determined using the curses module.  To see
 that, we'll provide a fake curses module:
@@ -115,7 +169,7 @@
     ...         return 60
     >>> old_curses = sys.modules.get('curses')
     >>> sys.modules['curses'] = FakeCurses()
-    >>> _ = testrunner.run(defaults)
+    >>> testrunner.run(defaults)
     Running tests at level 1
     Running samplelayers.Layer122 tests:
       Set up samplelayers.Layer1 in 0.000 seconds.
@@ -123,36 +177,64 @@
       Set up samplelayers.Layer122 in 0.000 seconds.
       Running:
         1/34 (2.9%) test_x1 (sample1.sampletests.test122.TestA)\r
+                                                               \r
         2/34 (5.9%) test_y0 (sample1.sampletests.test122.TestA)\r
+                                                               \r
         3/34 (8.8%) test_z0 (sample1.sampletests.test122.TestA)\r
+                                                               \r
         4/34 (11.8%) test_x0 (...le1.sampletests.test122.TestB)\r
+                                                               \r
         5/34 (14.7%) test_y1 (...le1.sampletests.test122.TestB)\r
+                                                               \r
         6/34 (17.6%) test_z0 (...le1.sampletests.test122.TestB)\r
+                                                               \r
         7/34 (20.6%) test_1 (...ampletests.test122.TestNotMuch)\r
+                                                               \r
         8/34 (23.5%) test_2 (...ampletests.test122.TestNotMuch)\r
+                                                               \r
         9/34 (26.5%) test_3 (...ampletests.test122.TestNotMuch)\r
-        10/34 (29.4%) test_x0 (sample1.sampletests.test122)    \r
+                                                               \r
+        10/34 (29.4%) test_x0 (sample1.sampletests.test122)\r
+                                                           \r
         11/34 (32.4%) test_y0 (sample1.sampletests.test122)\r
+                                                           \r
         12/34 (35.3%) test_z1 (sample1.sampletests.test122)\r
+                                                           \r
         17/34 (50.0%) ... e1/sampletests/../../sampletestsl.txt\r
-        18/34 (52.9%) test_x1 (sampletests.test122.TestA)      \r
+                                                               \r
+        18/34 (52.9%) test_x1 (sampletests.test122.TestA)\r
+                                                         \r
         19/34 (55.9%) test_y0 (sampletests.test122.TestA)\r
+                                                         \r
         20/34 (58.8%) test_z0 (sampletests.test122.TestA)\r
+                                                         \r
         21/34 (61.8%) test_x0 (sampletests.test122.TestB)\r
+                                                         \r
         22/34 (64.7%) test_y1 (sampletests.test122.TestB)\r
+                                                         \r
         23/34 (67.6%) test_z0 (sampletests.test122.TestB)\r
+                                                         \r
         24/34 (70.6%) test_1 (sampletests.test122.TestNotMuch)\r
+                                                              \r
         25/34 (73.5%) test_2 (sampletests.test122.TestNotMuch)\r
+                                                              \r
         26/34 (76.5%) test_3 (sampletests.test122.TestNotMuch)\r
-        27/34 (79.4%) test_x0 (sampletests.test122)           \r
+                                                              \r
+        27/34 (79.4%) test_x0 (sampletests.test122)\r
+                                                   \r
         28/34 (82.4%) test_y0 (sampletests.test122)\r
+                                                   \r
         29/34 (85.3%) test_z1 (sampletests.test122)\r
+                                                   \r
         34/34 (100.0%) ... r-ex/sampletests/../sampletestsl.txt\r
-      Ran 34 tests with 0 failures and 0 errors in 0.025 seconds.
+                                                               \r
+    <BLANKLINE>
+      Ran 34 tests with 0 failures and 0 errors in 0.008 seconds.
     Tearing down left over layers:
       Tear down samplelayers.Layer122 in 0.000 seconds.
       Tear down samplelayers.Layer12 in 0.000 seconds.
       Tear down samplelayers.Layer1 in 0.000 seconds.
+    False
 
     >>> sys.modules['curses'] = old_curses
 
@@ -168,29 +250,53 @@
       Set up samplelayers.Layer122 in 0.000 seconds.
       Running:
         1/24 (4.2%) test_x1 (sample1.sampletests.test122.TestA)\r
+                                                              \r
         2/24 (8.3%) test_y0 (sample1.sampletests.test122.TestA)\r
+                                                              \r
         3/24 (12.5%) test_z0 (sample1.sampletests.test122.TestA)\r
+                                                               \r
         4/24 (16.7%) test_x0 (sample1.sampletests.test122.TestB)\r
+                                                               \r
         5/24 (20.8%) test_y1 (sample1.sampletests.test122.TestB)\r
+                                                               \r
         6/24 (25.0%) test_z0 (sample1.sampletests.test122.TestB)\r
+                                                               \r
         7/24 (29.2%) test_1 (sample1.sampletests.test122.TestNotMuch)\r
+                                                                    \r
         8/24 (33.3%) test_2 (sample1.sampletests.test122.TestNotMuch)\r
+                                                                    \r
         9/24 (37.5%) test_3 (sample1.sampletests.test122.TestNotMuch)\r
-        10/24 (41.7%) test_x0 (sample1.sampletests.test122)          \r
+                                                                    \r
+        10/24 (41.7%) test_x0 (sample1.sampletests.test122)\r
+                                                          \r
         11/24 (45.8%) test_y0 (sample1.sampletests.test122)\r
+                                                          \r
         12/24 (50.0%) test_z1 (sample1.sampletests.test122)\r
-        13/24 (54.2%) test_x1 (sampletests.test122.TestA)  \r
+                                                          \r
+        13/24 (54.2%) test_x1 (sampletests.test122.TestA)\r
+                                                        \r
         14/24 (58.3%) test_y0 (sampletests.test122.TestA)\r
+                                                        \r
         15/24 (62.5%) test_z0 (sampletests.test122.TestA)\r
+                                                        \r
         16/24 (66.7%) test_x0 (sampletests.test122.TestB)\r
+                                                        \r
         17/24 (70.8%) test_y1 (sampletests.test122.TestB)\r
+                                                        \r
         18/24 (75.0%) test_z0 (sampletests.test122.TestB)\r
+                                                        \r
         19/24 (79.2%) test_1 (sampletests.test122.TestNotMuch)\r
+                                                             \r
         20/24 (83.3%) test_2 (sampletests.test122.TestNotMuch)\r
+                                                             \r
         21/24 (87.5%) test_3 (sampletests.test122.TestNotMuch)\r
-        22/24 (91.7%) test_x0 (sampletests.test122)           \r
+                                                             \r
+        22/24 (91.7%) test_x0 (sampletests.test122)\r
+                                                  \r
         23/24 (95.8%) test_y0 (sampletests.test122)\r
+                                                  \r
         24/24 (100.0%) test_z1 (sampletests.test122)\r
+                                                   \r
     <BLANKLINE>
       Ran 24 tests with 0 failures and 0 errors in 0.006 seconds.
     Tearing down left over layers:
@@ -211,23 +317,41 @@
       Set up samplelayers.Layer122 in 0.000 seconds.
       Running:
         1/18 (5.6%) test_x1 (sample1.sampletests.test122.TestA) (0.000 ms)\r
+                                                                          \r
         2/18 (11.1%) test_y0 (sample1.sampletests.test122.TestA) (0.000 ms)\r
+                                                                           \r
         3/18 (16.7%) test_z0 (sample1.sampletests.test122.TestA) (0.000 ms)\r
+                                                                           \r
         4/18 (22.2%) test_x0 (sample1.sampletests.test122.TestB) (0.000 ms)\r
+                                                                           \r
         5/18 (27.8%) test_y1 (sample1.sampletests.test122.TestB) (0.000 ms)\r
+                                                                           \r
         6/18 (33.3%) test_z0 (sample1.sampletests.test122.TestB) (0.000 ms)\r
-        7/18 (38.9%) test_x0 (sample1.sampletests.test122) (0.001 ms)      \r
+                                                                           \r
+        7/18 (38.9%) test_x0 (sample1.sampletests.test122) (0.001 ms)\r
+                                                                     \r
         8/18 (44.4%) test_y0 (sample1.sampletests.test122) (0.001 ms)\r
+                                                                     \r
         9/18 (50.0%) test_z1 (sample1.sampletests.test122) (0.001 ms)\r
-        10/18 (55.6%) test_x1 (sampletests.test122.TestA) (0.000 ms) \r
+                                                                     \r
+        10/18 (55.6%) test_x1 (sampletests.test122.TestA) (0.000 ms)\r
+                                                                    \r
         11/18 (61.1%) test_y0 (sampletests.test122.TestA) (0.000 ms)\r
+                                                                    \r
         12/18 (66.7%) test_z0 (sampletests.test122.TestA) (0.000 ms)\r
+                                                                    \r
         13/18 (72.2%) test_x0 (sampletests.test122.TestB) (0.000 ms)\r
+                                                                    \r
         14/18 (77.8%) test_y1 (sampletests.test122.TestB) (0.000 ms)\r
+                                                                    \r
         15/18 (83.3%) test_z0 (sampletests.test122.TestB) (0.000 ms)\r
-        16/18 (88.9%) test_x0 (sampletests.test122) (0.001 ms)      \r
+                                                                    \r
+        16/18 (88.9%) test_x0 (sampletests.test122) (0.001 ms)\r
+                                                              \r
         17/18 (94.4%) test_y0 (sampletests.test122) (0.001 ms)\r
+                                                              \r
         18/18 (100.0%) test_z1 (sampletests.test122) (0.001 ms)\r
+                                                               \r
     <BLANKLINE>
       Ran 18 tests with 0 failures and 0 errors in 0.006 seconds.
     Tearing down left over layers:
@@ -237,3 +361,7 @@
     False
 
 In this example, we also excluded tests with "NotMuch" in their names.
+
+Unfortunately, the time data above doesn't buy us much because, in
+practice, the line is cleared before there is time to see the
+times. :/

Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py	2005-11-01 23:54:35 UTC (rev 39837)
+++ zope.testing/trunk/src/zope/testing/testrunner.py	2005-11-02 00:15:33 UTC (rev 39838)
@@ -454,6 +454,7 @@
 
         t = time.time() - t
         if options.verbose == 1 or options.progress:
+            result.stopTests()
             print
         failures.extend(result.failures)
         errors.extend(result.errors)
@@ -649,6 +650,9 @@
         self.test_width = 0
 
         if options.progress:
+            if self.last_width:
+                sys.stdout.write('\r' + (' ' * self.last_width) + '\r')
+
             s = "    %d/%d (%.1f%%)" % (
                 self.testsRun, self.count,
                 (self.testsRun) * 100.0 / self.count
@@ -726,9 +730,12 @@
         self.test_width = self.last_width = 0
 
 
+    def stopTests(self):
+        if self.options.progress and self.last_width:
+            sys.stdout.write('\r' + (' ' * self.last_width) + '\r')
+
     def stopTest(self, test):
         if self.options.progress:
-            sys.stdout.write(' ' * (self.last_width - self.test_width) + "\r")
             self.last_width = self.test_width
         elif self.options.verbose > 1:
             print



More information about the Zope3-Checkins mailing list