コード例 #1
0
def test_none():
    """Test for None value as parameter"""
    with pytest.raises(TypeError):
        distance(None, 'b', 'c', 'd')
コード例 #2
0
def test_typical():
    """Test tupical coordinates"""
    assert distance(10, 15, 20, 5) == 14.142135623730951
コード例 #3
0
def test_points_order():
    """Test that the order of points does not matter"""
    distance1 = distance(10, 15, 20, 5)
    distance2 = distance(20, 5, 10, 15)
    assert distance1 == distance2
コード例 #4
0
def test_only_horizontal():
    """Test only vertical coordinates"""
    assert distance(1, 1, 5, 1) == 4
コード例 #5
0
def test_only_vertical():
    """Test only vertical coordinates"""
    assert distance(1, 1, 1, 5) == 4
コード例 #6
0
def test_negative():
    """Test for negative coordinates"""
    assert distance(-1, -3, -5, -6) == 5.0
コード例 #7
0
def test_zero_length():
    """Test for zero distance"""
    assert distance(1, 1, 1, 1) == 0
コード例 #8
0
def test_non_integer():
    """Test for no integer as parameter"""
    with pytest.raises(TypeError):
        distance('aoeu', 0, 1, 2)