[Zope3-checkins]
SVN: zope.testing/trunk/src/zope/testing/testrunner
Changed -vp to be compatible to old test runner.
Jim Fulton
jim at zope.com
Tue Nov 1 14:47:26 EST 2005
Log message for revision 39823:
Changed -vp to be compatible to old test runner.
Changed:
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-progress.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-progress.txt 2005-11-01 19:38:02 UTC (rev 39822)
+++ zope.testing/trunk/src/zope/testing/testrunner-progress.txt 2005-11-01 19:47:26 UTC (rev 39823)
@@ -61,50 +61,100 @@
(Note that, in the examples above and below, we show "\r" followed by
new lines where carriage returns would appear in actual output.)
-Using a single level of verbosity has only a small effect:
+Using a single level of verbosity causes test descriptions to be
+output, but only if they fit in the terminal width. The default
+width, when the terminal width can't be determined, is 80:
- >>> sys.argv = 'test --layer 122 -pv'.split()
- >>> testrunner.run(defaults)
+>>> sys.argv = 'test --layer 122 -pv'.split()
+>>> _ = testrunner.run(defaults)
+Running tests at level 1
+Running samplelayers.Layer122 tests:
+ Set up samplelayers.Layer1 in 0.000 seconds.
+ Set up samplelayers.Layer12 in 0.000 seconds.
+ Set up samplelayers.Layer122 in 0.000 seconds.
+ Running:
+ 1/34 (2.9%) test_x1 (sample1.sampletests.test122.TestA)\r
+ 2/34 (5.9%) test_y0 (sample1.sampletests.test122.TestA)\r
+ 3/34 (8.8%) test_z0 (sample1.sampletests.test122.TestA)\r
+ 4/34 (11.8%) test_x0 (sample1.sampletests.test122.TestB)\r
+ 5/34 (14.7%) test_y1 (sample1.sampletests.test122.TestB)\r
+ 6/34 (17.6%) test_z0 (sample1.sampletests.test122.TestB)\r
+ 7/34 (20.6%) test_1 (sample1.sampletests.test122.TestNotMuch)\r
+ 8/34 (23.5%) test_2 (sample1.sampletests.test122.TestNotMuch)\r
+ 9/34 (26.5%) test_3 (sample1.sampletests.test122.TestNotMuch)\r
+ 10/34 (29.4%) test_x0 (sample1.sampletests.test122) \r
+ 11/34 (32.4%) test_y0 (sample1.sampletests.test122)\r
+ 12/34 (35.3%) test_z1 (sample1.sampletests.test122)\r
+ 17/34 (50.0%) ... /testrunner-ex/sample1/sampletests/../../sampletestsl.txt\r
+ 18/34 (52.9%) test_x1 (sampletests.test122.TestA) \r
+ 19/34 (55.9%) test_y0 (sampletests.test122.TestA)\r
+ 20/34 (58.8%) test_z0 (sampletests.test122.TestA)\r
+ 21/34 (61.8%) test_x0 (sampletests.test122.TestB)\r
+ 22/34 (64.7%) test_y1 (sampletests.test122.TestB)\r
+ 23/34 (67.6%) test_z0 (sampletests.test122.TestB)\r
+ 24/34 (70.6%) test_1 (sampletests.test122.TestNotMuch)\r
+ 25/34 (73.5%) test_2 (sampletests.test122.TestNotMuch)\r
+ 26/34 (76.5%) test_3 (sampletests.test122.TestNotMuch)\r
+ 27/34 (79.4%) test_x0 (sampletests.test122) \r
+ 28/34 (82.4%) test_y0 (sampletests.test122)\r
+ 29/34 (85.3%) test_z1 (sampletests.test122)\r
+ 34/34 (100.0%) ... pe/testing/testrunner-ex/sampletests/../sampletestsl.txt\r
+ 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.
+
+The terminal width is determined using the curses module. To see
+that, we'll provide a fake curses module:
+
+ >>> class FakeCurses:
+ ... def setupterm(self):
+ ... pass
+ ... def tigetnum(self, ignored):
+ ... return 60
+ >>> old_curses = sys.modules.get('curses')
+ >>> sys.modules['curses'] = FakeCurses()
+ >>> _ = testrunner.run(defaults)
Running tests at level 1
Running samplelayers.Layer122 tests:
Set up samplelayers.Layer1 in 0.000 seconds.
Set up samplelayers.Layer12 in 0.000 seconds.
Set up samplelayers.Layer122 in 0.000 seconds.
Running:
- 1/34 (2.9%)\r
- 2/34 (5.9%)\r
- 3/34 (8.8%)\r
- 4/34 (11.8%)\r
- 5/34 (14.7%)\r
- 6/34 (17.6%)\r
- 7/34 (20.6%)\r
- 8/34 (23.5%)\r
- 9/34 (26.5%)\r
- 10/34 (29.4%)\r
- 11/34 (32.4%)\r
- 12/34 (35.3%)\r
- 17/34 (50.0%)\r
- 18/34 (52.9%)\r
- 19/34 (55.9%)\r
- 20/34 (58.8%)\r
- 21/34 (61.8%)\r
- 22/34 (64.7%)\r
- 23/34 (67.6%)\r
- 24/34 (70.6%)\r
- 25/34 (73.5%)\r
- 26/34 (76.5%)\r
- 27/34 (79.4%)\r
- 28/34 (82.4%)\r
- 29/34 (85.3%)\r
- 34/34 (100.0%)\r
- <BLANKLINE>
- Ran 34 tests with 0 failures and 0 errors in 0.009 seconds.
+ 1/34 (2.9%) test_x1 (sample1.sampletests.test122.TestA)\r
+ 2/34 (5.9%) test_y0 (sample1.sampletests.test122.TestA)\r
+ 3/34 (8.8%) test_z0 (sample1.sampletests.test122.TestA)\r
+ 4/34 (11.8%) test_x0 (...le1.sampletests.test122.TestB)\r
+ 5/34 (14.7%) test_y1 (...le1.sampletests.test122.TestB)\r
+ 6/34 (17.6%) test_z0 (...le1.sampletests.test122.TestB)\r
+ 7/34 (20.6%) test_1 (...ampletests.test122.TestNotMuch)\r
+ 8/34 (23.5%) test_2 (...ampletests.test122.TestNotMuch)\r
+ 9/34 (26.5%) test_3 (...ampletests.test122.TestNotMuch)\r
+ 10/34 (29.4%) test_x0 (sample1.sampletests.test122) \r
+ 11/34 (32.4%) test_y0 (sample1.sampletests.test122)\r
+ 12/34 (35.3%) test_z1 (sample1.sampletests.test122)\r
+ 17/34 (50.0%) ... e1/sampletests/../../sampletestsl.txt\r
+ 18/34 (52.9%) test_x1 (sampletests.test122.TestA) \r
+ 19/34 (55.9%) test_y0 (sampletests.test122.TestA)\r
+ 20/34 (58.8%) test_z0 (sampletests.test122.TestA)\r
+ 21/34 (61.8%) test_x0 (sampletests.test122.TestB)\r
+ 22/34 (64.7%) test_y1 (sampletests.test122.TestB)\r
+ 23/34 (67.6%) test_z0 (sampletests.test122.TestB)\r
+ 24/34 (70.6%) test_1 (sampletests.test122.TestNotMuch)\r
+ 25/34 (73.5%) test_2 (sampletests.test122.TestNotMuch)\r
+ 26/34 (76.5%) test_3 (sampletests.test122.TestNotMuch)\r
+ 27/34 (79.4%) test_x0 (sampletests.test122) \r
+ 28/34 (82.4%) test_y0 (sampletests.test122)\r
+ 29/34 (85.3%) test_z1 (sampletests.test122)\r
+ 34/34 (100.0%) ... r-ex/sampletests/../sampletestsl.txt\r
+ Ran 34 tests with 0 failures and 0 errors in 0.025 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
If a second or third level of verbosity are added, we get additional
information.
Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py 2005-11-01 19:38:02 UTC (rev 39822)
+++ zope.testing/trunk/src/zope/testing/testrunner.py 2005-11-01 19:47:26 UTC (rev 39823)
@@ -591,10 +591,10 @@
result[base] = 1
dependencies(base.__bases__, result)
+class TestResult(unittest.TestResult):
+ max_width = 80
-class TestResult(unittest.TestResult):
-
def __init__(self, options, tests):
unittest.TestResult.__init__(self)
self.options = options
@@ -605,6 +605,36 @@
self.count = count
self.last_width = 0
+ if options.progress:
+ try:
+ # Note that doing this every time is more test friendly.
+ import curses
+ curses.setupterm()
+ except (ImportError, TypeError):
+ pass
+ else:
+ self.max_width = curses.tigetnum('cols')
+
+ def getShortDescription(self, test, room):
+ room -= 1
+ s = str(test)
+ if len(s) > room:
+ pos = s.find(" (")
+ if pos >= 0:
+ w = room - (pos + 5)
+ if w < 1:
+ # first portion (test method name) is too long
+ s = s[:room-3] + "..."
+ else:
+ pre = s[:pos+2]
+ post = s[-w:]
+ s = "%s...%s" % (pre, post)
+ else:
+ w = room - 4
+ s = '... ' + s[-w:]
+
+ return ' ' + s[:room]
+
def startTest(self, test):
unittest.TestResult.startTest(self, test)
testsRun = self.testsRun - 1
@@ -620,6 +650,11 @@
)
sys.stdout.write(s)
self.test_width += len(s)
+ if options.verbose == 1:
+ room = self.max_width - self.test_width - 1
+ s = self.getShortDescription(test, room)
+ sys.stdout.write(s)
+ self.test_width += len(s)
elif options.verbose == 1:
for i in range(count):
More information about the Zope3-Checkins
mailing list