Example #1
0
class TestValidInputs(unittest.TestCase):
    def setUp(self):
        self.stats = StatsList([1, 2, 2, 3, 3, 4])

    # END setUp

    def test_mean(self):
        self.assertEqual(self.stats.mean(), 2.5)
        self.stats.append(3)
        self.assertEqual(self.stats.mean(), 2.5)
        self.stats.append(2)
        self.assertEqual(self.stats.mean(), 2.5)

    # END test_mean

    def test_median(self):
        self.assertEqual(self.stats.median(), 2.5)
        self.stats.append(4)
        self.assertEqual(self.stats.median(), 3)
        self.stats.append(3)
        self.assertEqual(self.stats.median(), 3)

    # END test_median

    def test_mode(self):
        self.assertEqual(self.stats.mode(), [2, 3])
        self.stats.remove(2)
        self.assertEqual(self.stats.mode(), [3])
        self.stats.append(3)
        self.assertEqual(self.stats.mode(), [3])

    def test_smallest(self):
        self.assertEqual(self.stats.smallest(), [1])
Example #2
0
class TestValidInputs(unittest.TestCase):
    def setUp(self):
        self.stats = StatsList([1,2,2,3,3,4])

    def test_mean(self):
        self.assertEqual(self.stats.mean(), 2.0)

    def test_median(self):
        self.assertEqual(self.stats.median(), 2.0)
        self.stats.append(4)
        self.assertEqual(self.stats.median(), 3)

    def test_mode(self):
        self.assertEqual(self.stats.mode(), [2,3])
        self.stats.remove(2)
        self.assertEqual(self.stats.mode(), [3])
Example #3
0
class TestValidInputs(unittest.TestCase):
    # this is the method that gets called as setup
    def setUp(self):
        self.stats = StatsList([1, 2, 2, 3, 3, 4])

    def test_main(self):
        self.assertEqual(self.stats.mean(), 2.5)

    def test_median(self):
        self.assertEqual(self.stats.median(), 2.5)
        self.stats.append(4)
        self.assertEqual(self.stats.median(), 3)

    def test_mode(self):
        self.assertEqual(self.stats.mode(), [2, 3])
        self.stats.remove(2)
        self.assertEqual(self.stats.mode(), [3])
Example #4
0
class TestValidInputs(unittest.TestCase):
    def setUp(self):
    	"""
    	To do initialization for each test.
    	No need to explicitly called. It is
    	called individually before each test.
    	"""
        self.stats = StatsList([1,2,2,3,3,4])

    def test_mean(self):
        self.assertEqual(self.stats.mean(), 2.5)

    def test_median(self):
        self.assertEqual(self.stats.median(), 2.5)
        self.stats.append(4)
        self.assertEqual(self.stats.median(), 3)

    def test_mode(self):
        self.assertEqual(self.stats.mode(), [2,3])
        self.stats.remove(2)
        self.assertEqual(self.stats.mode(), [3])
class TestValidInputs(unittest.TestCase):
    def setUp(self):
        """
        This method is called individually before each test* method. The tests
        can be executed in any order because the tests do not depend on any
        other tests.
        :return: None
        """
        self.stats = StatsList([1, 2, 2, 3, 3, 4])

    def test_mean(self):
        self.assertEqual(self.stats.mean(), 2.5)

    def test_median(self):
        self.assertEqual(self.stats.median(), 2.5)
        self.stats.append(4)
        self.assertEqual(self.stats.median(), 3)

    def test_mode(self):
        self.assertEqual(self.stats.mode(), [2, 3])
        self.stats.remove(2)
        self.assertEqual(self.stats.mode(), [3])