def testParse(self): stat = stopwatch.Stat() stat.add(1) stat.add(3) out = str(stat) self.assertEqual(out, "sum: 4.0000, avg: 2.0000, dev: 1.0000, " "min: 1.0000, max: 3.0000, num: 2") # Allow a few small rounding errors self.assertLess(ham_dist(out, str(stopwatch.Stat.parse(out))), 5)
def testRange(self): stat = stopwatch.Stat() stat.add(1) stat.add(5) stat.add(3) self.assertEqual(stat.num, 3) self.assertEqual(stat.sum, 9) self.assertEqual(stat.min, 1) self.assertEqual(stat.max, 5) self.assertEqual(stat.avg, 3)