Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(850)

Unified Diff: appengine/findit/crash/test/occurrence_test.py

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Finally fixed the mock tests! Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/test/findit_test.py ('k') | appengine/findit/crash/test/project_classifier_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/test/occurrence_test.py
diff --git a/appengine/findit/crash/test/classifier_test.py b/appengine/findit/crash/test/occurrence_test.py
similarity index 75%
rename from appengine/findit/crash/test/classifier_test.py
rename to appengine/findit/crash/test/occurrence_test.py
index 782a0c6219b40f2e3c0f1d674868f4194861571e..f89b45c97f60828a97c15ce71accf75cc9a25c1a 100644
--- a/appengine/findit/crash/test/classifier_test.py
+++ b/appengine/findit/crash/test/occurrence_test.py
@@ -4,16 +4,16 @@
from common import constants
from common.pipeline_wrapper import pipeline_handlers
-from crash.classifier import Occurrence
-from crash.classifier import Classifier
-from crash.classifier import DefaultRankFunction
+from crash.occurrence import Occurrence
+from crash.occurrence import DefaultOccurrenceRanking
+from crash.occurrence import RankByOccurrence
from crash.stacktrace import StackFrame
from crash.stacktrace import CallStack
from crash.results import Result
from crash.test.crash_testcase import CrashTestCase
-class DummyClassifier(Classifier):
+class DummyClassifier(object):
def GetClassFromStackFrame(self, frame):
if frame.dep_path == 'src/':
@@ -21,11 +21,17 @@ class DummyClassifier(Classifier):
return 'class_2'
- def GetClassFromResult(self, result): # pragma: no cover.
+ def GetClassFromResult(self, _result): # pragma: no cover.
return 'class_3'
def Classify(self, results, crash_stack):
- class_list = self._Classify(results, crash_stack, 4, 1)
+ top_n_frames = 4
+ if results:
+ classes = map(self.GetClassFromResult, results[:top_n_frames])
+ else:
+ classes = map(self.GetClassFromStackFrame, crash_stack[:top_n_frames])
+
+ class_list = RankByOccurrence(classes, 1)
if class_list:
return class_list[0]
@@ -34,10 +40,10 @@ class DummyClassifier(Classifier):
class ClassifierTest(CrashTestCase):
- def testDefaultRankFunction(self):
- self.assertEqual(DefaultRankFunction(Occurrence('c1', [0])),
+ def testDefaultOccurrenceRanking(self):
+ self.assertEqual(DefaultOccurrenceRanking(Occurrence('c1', [0])),
(-1, 0))
- self.assertEqual(DefaultRankFunction(Occurrence('c1', [0, 1])),
+ self.assertEqual(DefaultOccurrenceRanking(Occurrence('c1', [0, 1])),
(-float('inf'), 0))
def testClassifyCrashStack(self):
@@ -73,4 +79,3 @@ class ClassifierTest(CrashTestCase):
self.assertEqual(dummy_classifier.Classify([result], CallStack(0)),
'class_3')
-
« no previous file with comments | « appengine/findit/crash/test/findit_test.py ('k') | appengine/findit/crash/test/project_classifier_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698