def testPercentileFailure(self): p = PercentileTracker(25, 85) lst = [4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10] p.add_list(lst) self.assertRaises(PercentileNotTrackedError, p.get_percentile, 80)
def testPercentileTracker(self): p = PercentileTracker(25, 85) lst = [4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10] p.add_list(lst) self.assertEquals(5, p.get_percentile(25)) self.failUnlessAlmostEqual(9.85, p.get_percentile(85))