| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import unittest | 5 import unittest |
| 6 | 6 |
| 7 from infra_libs.ts_mon import distribution | 7 try: |
| 8 from infra_libs.ts_mon.common import distribution |
| 9 except ImportError: |
| 10 from common import distribution |
| 8 | 11 |
| 9 | 12 |
| 10 class BucketerTestBase(unittest.TestCase): | 13 class BucketerTestBase(unittest.TestCase): |
| 11 def assertBucketCounts(self, b, expected_total): | 14 def assertBucketCounts(self, b, expected_total): |
| 12 self.assertEquals(expected_total - 2, b.num_finite_buckets) | 15 self.assertEquals(expected_total - 2, b.num_finite_buckets) |
| 13 self.assertEquals(expected_total, b.total_buckets) | 16 self.assertEquals(expected_total, b.total_buckets) |
| 14 self.assertEquals(0, b.underflow_bucket) | 17 self.assertEquals(0, b.underflow_bucket) |
| 15 self.assertEquals(expected_total - 1, b.overflow_bucket) | 18 self.assertEquals(expected_total - 1, b.overflow_bucket) |
| 16 | 19 |
| 17 def assertBoundaries(self, b, expected_finite_upper_boundaries): | 20 def assertBoundaries(self, b, expected_finite_upper_boundaries): |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 158 |
| 156 self.assertEqual(100, d.sum) | 159 self.assertEqual(100, d.sum) |
| 157 self.assertEqual(1, d.count) | 160 self.assertEqual(1, d.count) |
| 158 self.assertEqual({11: 1}, d.buckets) | 161 self.assertEqual({11: 1}, d.buckets) |
| 159 | 162 |
| 160 d.add(1000000) | 163 d.add(1000000) |
| 161 | 164 |
| 162 self.assertEqual(1000100, d.sum) | 165 self.assertEqual(1000100, d.sum) |
| 163 self.assertEqual(2, d.count) | 166 self.assertEqual(2, d.count) |
| 164 self.assertEqual({11: 2}, d.buckets) | 167 self.assertEqual({11: 2}, d.buckets) |
| OLD | NEW |