示例#1
0
 def test_heron_perfect_root(self):
     expected = 10.0
     actual = exceptions.heron(100)
     self.assertEqual(actual, expected)
示例#2
0
 def test_heron_error_print_value(self, mock_stdout):
     exceptions.heron(-1)
     expected = "Error: The number provided must be positive!\n"
     self.assertEqual(expected, mock_stdout.getvalue())
示例#3
0
 def test_heron_error_zero(self):
     actual = exceptions.heron(-1)
     expected = -1
     self.assertEqual(actual, expected)
示例#4
0
 def test_heron_float(self):
     expected = math.sqrt(5.5)
     actual = exceptions.heron(5.5)
     self.assertAlmostEqual(actual, expected)
示例#5
0
 def test_heron_non_perfect_int(self):
     expected = math.sqrt(42)
     actual = exceptions.heron(42)
     self.assertAlmostEqual(actual, expected)
示例#6
0
 def test_heron_negative_number(self):
     """Test function with a negative number"""
     argument = -100
     expected = -1
     actual = heron(argument)
     self.assertEqual(expected, actual)
示例#7
0
 def test_heron_zero(self):
     """Test function with 0"""
     argument = 0
     expected = 0
     actual = heron(argument)
     self.assertEqual(expected, actual)
示例#8
0
 def test_heron_positive_number(self):
     """Test function with a positive number"""
     argument = 4
     expected = 2.0
     actual = heron(argument)
     self.assertEqual(expected, actual)
示例#9
0
 def test_heron_negative_one(self):
     """Test function with -1"""
     argument = -1
     expected = -1
     actual = heron(argument)
     self.assertEqual(expected, actual)
示例#10
0
 def test_heron_negative(self):
     actual = exceptions.heron(-21)
     expected = -1
     self.assertEqual(actual, expected)
示例#11
0
 def test_heron_1(self):
     """Test function with 1"""
     argument = 1
     expected = 1.0
     actual = heron(argument)
     self.assertEqual(expected, actual)
示例#12
0
 def test_heron_root_is_float(self):
     actual = exceptions.heron(1000)
     expected = 31.62
     self.assertEqual(actual, expected)
示例#13
0
 def test_heron_root_is_integer(self):
     actual = exceptions.heron(100)
     expected = 10.0
     self.assertEqual(actual, expected)
示例#14
0
 def test_heron_one(self):
     actual = exceptions.heron(1)
     expected = 1.0
     self.assertEqual(actual, expected)
示例#15
0
 def test_heron_between_zero_and_one(self):
     actual = exceptions.heron(0.25)
     expected = 0.5
     self.assertEqual(actual, expected)
示例#16
0
 def test_heron_zero(self):
     actual = exceptions.heron(0)
     expected = 0.0
     self.assertEqual(actual, expected)