From 12c9b4dede9471a9b53e66538d68e57755a48062 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Wed, 4 Aug 2010 10:08:49 +0200 Subject: Stop walking up the traceback as soon as possible. This is done by letting the score calculation return a value between 0.0 and 1.0. If we find a frame with a score of 1.0 in the middle of it, we can immediately stop searching further, as this will be the best match. --- machineout.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'machineout.py') diff --git a/machineout.py b/machineout.py index 8a09689..8c0495b 100644 --- a/machineout.py +++ b/machineout.py @@ -48,7 +48,8 @@ class NoseMachineReadableOutput(Plugin): """ fname, _, funname, _ = frame - score = 0 + score = 0.0 + max_score = 7.0 # update this when new conditions are added # Being in the project directory means it's one of our own files if fname.startswith(self.basepath): @@ -63,7 +64,7 @@ class NoseMachineReadableOutput(Plugin): # machineout still returns the most useful error line number. if not funname.startswith('assert'): score += 1 - return score + return score / max_score def _selectBestStackFrame(self, traceback): best_score = 0 @@ -73,6 +74,10 @@ class NoseMachineReadableOutput(Plugin): if curr_score > best_score: best = frame best_score = curr_score + + # Terminate the walk as soon as possible + if best_score >= 1: + break return best def add_formatted(self, etype, err): -- cgit v1.2.3