# Copyright (C) 2010 Peter Teichman

import unittest

from instatrace.stats import Statistics

class testStatistics(unittest.TestCase):
    def testStats(self):
        name = "test_stat"
        s = Statistics()

        s.add_sample(name, 1)
        s.add_sample(name, 2)
        s.add_sample(name, 3)

        test_stat = s.statistics.get(name)

        self.assertEqual(name, test_stat._name)

        stats = test_stat.stats()

        self.assertEqual(3, stats.get("count"))
        self.assertEqual(6, stats.get("total"))
        self.assertAlmostEqual(2, stats.get("mean"))
        self.assertAlmostEqual(0.8164966, stats.get("stddev"))

@@ -634,12 +634,528 @@
 (%22stddev%22))%0A
+%0A    def testStandardDeviation(self):%0A        name = %22test_stat%22%0A%0A        s = Statistics()%0A%0A        s.add_sample(name, 2)%0A        s.add_sample(name, 4)%0A        s.add_sample(name, 4)%0A        s.add_sample(name, 4)%0A        s.add_sample(name, 5)%0A        s.add_sample(name, 5)%0A        s.add_sample(name, 7)%0A        s.add_sample(name, 9)%0A%0A        test_stat = s.statistics.get(name)%0A%0A        self.assertEqual(name, test_stat._name)%0A%0A        stats = test_stat.stats()%0A%0A        self.assertAlmostEqual(2, stats.get(%22stddev%22))%0A

Implement testStandardDeviation