simplify durations output, no percentage, no "remaining" bits

This commit is contained in:
holger krekel 2011-11-08 20:57:19 +00:00
parent 0b18b6094e
commit 99a1188287
4 changed files with 10 additions and 16 deletions

View File

@ -1,2 +1,2 @@
# #
__version__ = '2.2.0.dev4' __version__ = '2.2.0.dev5'

View File

@ -26,35 +26,31 @@ def pytest_terminal_summary(terminalreporter):
return return
tr = terminalreporter tr = terminalreporter
duration2rep = {} duration2rep = {}
alldurations = 0.0
for key, replist in tr.stats.items(): for key, replist in tr.stats.items():
for rep in replist: for rep in replist:
if hasattr(rep, 'duration'): if hasattr(rep, 'duration'):
duration2rep[rep.duration] = rep duration2rep[rep.duration] = rep
alldurations += rep.duration
if not duration2rep: if not duration2rep:
return return
d2 = list(duration2rep.items()) d2 = list(duration2rep.items())
d2.sort() d2.sort()
d2.reverse() d2.reverse()
remaining = [] #remaining = []
if not durations: if not durations:
tr.write_sep("=", "slowest test durations") tr.write_sep("=", "slowest test durations")
else: else:
tr.write_sep("=", "slowest %s test durations" % durations) tr.write_sep("=", "slowest %s test durations" % durations)
remaining = d2[durations:] #remaining = d2[durations:]
d2 = d2[:durations] d2 = d2[:durations]
assert (alldurations/100) > 0
for duration, rep in d2: for duration, rep in d2:
nodeid = rep.nodeid.replace("::()::", "::") nodeid = rep.nodeid.replace("::()::", "::")
percent = rep.duration / (alldurations / 100) tr.write_line("%02.2fs %s %s" %
tr.write_line("%02.2fs %-02.2f%% %s %s" % (duration, rep.when, nodeid))
(duration, percent, rep.when, nodeid)) #if remaining:
if remaining: # remsum = sum(map(lambda x: x[0], remaining))
remsum = sum(map(lambda x: x[0], remaining)) # tr.write_line("%02.2fs spent in %d remaining test phases" %(
tr.write_line("%02.2fs %-02.2f%% remaining in %d test phases" %( # remsum, len(remaining)))
remsum, remsum / (alldurations / 100), len(remaining)))
def pytest_sessionstart(session): def pytest_sessionstart(session):

View File

@ -24,7 +24,7 @@ def main():
name='pytest', name='pytest',
description='py.test: simple powerful testing with Python', description='py.test: simple powerful testing with Python',
long_description = long_description, long_description = long_description,
version='2.2.0.dev4', version='2.2.0.dev5',
url='http://pytest.org', url='http://pytest.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -487,7 +487,6 @@ class TestDurations:
"*call*test_2*", "*call*test_2*",
"*call*test_1*", "*call*test_1*",
]) ])
assert "remaining in" not in result.stdout.str()
def test_calls_show_2(self, testdir): def test_calls_show_2(self, testdir):
testdir.makepyfile(self.source) testdir.makepyfile(self.source)
@ -497,7 +496,6 @@ class TestDurations:
"*durations*", "*durations*",
"*call*test_3*", "*call*test_3*",
"*call*test_2*", "*call*test_2*",
"*s*%*remaining in 7 test phases",
]) ])
assert "test_1" not in result.stdout.str() assert "test_1" not in result.stdout.str()