コード例 #1
0
 def test_not_numeric_values_in_list(self):
     """
     This test checks if the function deals correctly with list with not numeric values given as an argument.
     """
     with self.assertRaises(TypeError) as error:
         median([1, 'a'])
     self.assertEqual(error.exception.args[0], 'argument of the function must be a list of values of type int '
                                               'or float')
コード例 #2
0
 def test_not_a_list(self):
     """
     This test checks if the function deals correctly with not a list argument.
     """
     with self.assertRaises(TypeError) as error:
         median('a')
     self.assertEqual(error.exception.args[0], 'argument of the function must be a list of values of type int '
                                               'or float')
コード例 #3
0
ファイル: test_stats.py プロジェクト: klimente/kekakek
 def test_median(self):
     self.assertEqual(stats.median([1, 2, 3, 4]), 2.5)
     self.assertEqual(stats.median([1, 2, 3, 4, 5]), 3)
コード例 #4
0
 def test_harder_int_list(self):
     """
     This test checks if the function deals correctly with list [1, 1, 2, 2, 1, 3, 5, 6, 7, 5].
     """
     self.assertEqual(median([1, 1, 2, 2, 1, 3, 5, 6, 7, 5]), 2.5)
コード例 #5
0
 def test_simple_float_list(self):
     """
     This test checks if the function deals correctly with list [1.21, -3.42, 5.56, 112.86, -34].
     """
     self.assertEqual(median([1.21, -3.42, 5.56, 112.86, -34]), 1.21)
コード例 #6
0
 def test_simple_int_list(self):
     """
     This test checks if the function deals correctly with list [1, 1, 1, 1, 1, 2, 3, 4, 5].
     """
     self.assertEqual(median([1, 1, 1, 1, 1, 2, 3, 4, 5]), 1)
コード例 #7
0
 def test_one_element(self):
     """
     This test checks if the function deals correctly with list of one element.
     """
     self.assertEqual(median([1]), 1.0)