From f7648e11d80af1f1afa9af5d8fb989524508ba2f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 18 Nov 2011 17:59:52 +0000 Subject: [PATCH] another try to properly fix durations sorting (still producing sometimes failing tests, apparently when two durations of a test report are identical) --- _pytest/runner.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_pytest/runner.py b/_pytest/runner.py index d4afad96f..b13a664ed 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -29,10 +29,10 @@ def pytest_terminal_summary(terminalreporter): for replist in tr.stats.values(): for rep in replist: if hasattr(rep, 'duration'): - dlist.append((rep.duration, rep)) + dlist.append(rep) if not dlist: return - dlist.sort() + dlist.sort(key=lambda x: x.duration) dlist.reverse() if not durations: tr.write_sep("=", "slowest test durations") @@ -40,10 +40,10 @@ def pytest_terminal_summary(terminalreporter): tr.write_sep("=", "slowest %s test durations" % durations) dlist = dlist[:durations] - for duration, rep in dlist: + for rep in dlist: nodeid = rep.nodeid.replace("::()::", "::") tr.write_line("%02.2fs %-8s %s" % - (duration, rep.when, nodeid)) + (rep.duration, rep.when, nodeid)) def pytest_sessionstart(session): session._setupstate = SetupState()