コード例 #1
0
 def test_order_of_points(self):
     dist_1 = distance(1.2, 3.4, 5.6, 7.8)
     dist_2 = distance(5.6, 7.8, 1.2, 3.4)
     assert self.are_floats_equal(dist_1, dist_2)
コード例 #2
0
 def test_horizontal_distance(self):
     result = distance(1.2, 3.4, 5.6, 3.4)
     assert self.are_floats_equal(result, 4.4)
コード例 #3
0
 def test_typical_values(self):
     result = distance(1.2, 3.4, 5.6, 7.8)
     assert self.are_floats_equal(result, 6.22254)
コード例 #4
0
 def test_vertical_distance(self):
     result = distance(1.2, 3.4, 1.2, 5.6)
     assert self.are_floats_equal(result, 2.2)
コード例 #5
0
 def test_negative_coordinates(self):
     result = distance(-1.2, -3.4, -5.6, -7.8)
     assert self.are_floats_equal(result, 6.22254)
コード例 #6
0
 def test_zero_length(self):
     result = distance(1.2, 3.4, 1.2, 3.4)
     assert self.are_floats_equal(result, 0.0)
コード例 #7
0
 def test_value_error(self):
     with pytest.raises(ValueError):
         distance('aeou', 1.2, 3.4, 5.6)
コード例 #8
0
 def test_type_error(self):
     with pytest.raises(TypeError):
         distance(None, 1.2, 3.4, 5.6)