summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Driessen <vincent@datafox.nl>2010-08-04 10:08:49 +0200
committerVincent Driessen <vincent@datafox.nl>2010-08-04 10:08:49 +0200
commit12c9b4dede9471a9b53e66538d68e57755a48062 (patch)
tree3f312b51a64b4a8449bdefa1b7e98f78c0c420cd
parenta380c9b99cc9b790b9daa62bbb996735d11bded3 (diff)
downloadnose-machineout-12c9b4dede9471a9b53e66538d68e57755a48062.tar.bz2
nose-machineout-12c9b4dede9471a9b53e66538d68e57755a48062.tar.xz
nose-machineout-12c9b4dede9471a9b53e66538d68e57755a48062.zip
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.
-rw-r--r--machineout.py9
1 files changed, 7 insertions, 2 deletions
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):
48 48
49 """ 49 """
50 fname, _, funname, _ = frame 50 fname, _, funname, _ = frame
51 score = 0 51 score = 0.0
52 max_score = 7.0 # update this when new conditions are added
52 53
53 # Being in the project directory means it's one of our own files 54 # Being in the project directory means it's one of our own files
54 if fname.startswith(self.basepath): 55 if fname.startswith(self.basepath):
@@ -63,7 +64,7 @@ class NoseMachineReadableOutput(Plugin):
63 # machineout still returns the most useful error line number. 64 # machineout still returns the most useful error line number.
64 if not funname.startswith('assert'): 65 if not funname.startswith('assert'):
65 score += 1 66 score += 1
66 return score 67 return score / max_score
67 68
68 def _selectBestStackFrame(self, traceback): 69 def _selectBestStackFrame(self, traceback):
69 best_score = 0 70 best_score = 0
@@ -73,6 +74,10 @@ class NoseMachineReadableOutput(Plugin):
73 if curr_score > best_score: 74 if curr_score > best_score:
74 best = frame 75 best = frame
75 best_score = curr_score 76 best_score = curr_score
77
78 # Terminate the walk as soon as possible
79 if best_score >= 1:
80 break
76 return best 81 return best
77 82
78 def add_formatted(self, etype, err): 83 def add_formatted(self, etype, err):