• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import unittest
6
7import bisect_results
8import ttest
9
10
11class ConfidenceScoreTest(unittest.TestCase):
12
13  def testConfidenceScoreIsZeroOnTooFewLists(self):
14    self.assertEqual(bisect_results.ConfidenceScore([], [[1], [2]]), 0.0)
15    self.assertEqual(bisect_results.ConfidenceScore([[1], [2]], []), 0.0)
16    self.assertEqual(bisect_results.ConfidenceScore([[1]], [[1], [2]]), 0.0)
17    self.assertEqual(bisect_results.ConfidenceScore([[1], [2]], [[1]]), 0.0)
18
19  def testConfidenceScoreIsZeroOnEmptyLists(self):
20    self.assertEqual(bisect_results.ConfidenceScore([[], []], [[1], [2]]), 0.0)
21    self.assertEqual(bisect_results.ConfidenceScore([[1], [2]], [[], []]), 0.0)
22
23  def testConfidenceScoreIsUsingTTestWelchsTTest(self):
24    original_WelchsTTest = ttest.WelchsTTest
25    try:
26      ttest.WelchsTTest = lambda _sample1, _sample2: (0, 0, 0.42)
27      self.assertAlmostEqual(
28        bisect_results.ConfidenceScore([[1], [1]], [[2], [2]]), 58.0)
29    finally:
30      ttest.WelchsTTest = original_WelchsTTest
31
32
33class BisectResulstsTest(unittest.TestCase):
34  # TODO(sergiyb): Write tests for GetResultDicts when it is broken into smaller
35  # pieces.
36  pass
37
38
39if __name__ == '__main__':
40  unittest.main()
41