
import unittest

from instatrace.stats import Statistic

class testStatistic(unittest.TestCase):
    def testName(self):
        name = "test_stat"
        s = Statistic(name, [])

        self.assertEqual(name, s.name)


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"))

Implement testStatistics with count, total, mean, and stddev checks
Implement testStatistics with count, total, mean, and stddev checks

  
  import unittest
  
- from instatrace.stats import Statistic
+ from instatrace.stats import Statistics
  
- class testStatistic(unittest.TestCase):
+ class testStatistics(unittest.TestCase):
-     def testName(self):
+     def testStats(self):
          name = "test_stat"
-         s = Statistic(name, [])
+         s = Statistics()
  
-         self.assertEqual(name, s.name)
+         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"))
+ 
Implement testStatistics with count, total, mean, and stddev checks
## Code Before:

import unittest

from instatrace.stats import Statistic

class testStatistic(unittest.TestCase):
    def testName(self):
        name = "test_stat"
        s = Statistic(name, [])

        self.assertEqual(name, s.name)

## Instruction:
Implement testStatistics with count, total, mean, and stddev checks
## Code After:

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"))
