def test_rectangle():
    for w in range(1, 100):
        for h in range(1, 100):
            w, h = 5, 4
            rect = Rectangle(w, h)
            assert rect.get_area() == w * h
            assert rect.get_perimeter() == (w + h) * 2
def test_valid_constructor():
    for i in range(1, 100):
        for j in range(1, 100):
            try:
                Rectangle(i, j)
            except ValueError:
                pytest.fail("Unexpected error")
Beispiel #3
0
def test_zero_height_area():
    r = Rectangle(1, 0)
    assert r.get_area() == 0
def test_error_type_input1():
    with pytest.raises(TypeError):
        Rectangle('a', 10)
Beispiel #5
0
def test_simple_2():
    assert Rectangle(2, 3).get_perimeter() == 10
Beispiel #6
0
def test_value_2():
    with r(ValueError):
        Rectangle(-12, 2)
Beispiel #7
0
def test_type_2():
    with r(TypeError):
        Rectangle('s', 1)
Beispiel #8
0
def test_wrong_type():
    with pytest.raises(TypeError):
        r = Rectangle(None, '42')
Beispiel #9
0
def test_area():
    r = Rectangle(2, 3)
    assert r.get_area() == 6
def test_normal_get_area():
    assert Rectangle(4, 10).get_area() == 40
def test_normal_int_input():
    assert Rectangle(4, 10)
def test_error_minus_int2():
    with pytest.raises(ValueError):
        Rectangle(20, -1)
def test_error_minus_int1():
    with pytest.raises(ValueError):
        Rectangle(-1, 20)
def test_error_type_input2():
    with pytest.raises(TypeError):
        Rectangle(10, 'a')
Beispiel #15
0
def test_zero_width_perimeter():
    r = Rectangle(0, 1)
    assert r.get_perimeter() == 2
Beispiel #16
0
def test_zero_height_perimeter():
    r = Rectangle(1, 0)
    assert r.get_perimeter() == 2
def test_invalid_type_3():
    with pytest.raises(TypeError):
        Rectangle([], [])
Beispiel #18
0
def test_perimeter():
    r = Rectangle(2, 3)
    assert r.get_perimeter() == 10
def test_invalid_type_4():
    with pytest.raises(TypeError):
        Rectangle("hi", 4)
Beispiel #20
0
def test_wrong_values():
    with pytest.raises(ValueError):
        r = Rectangle(-1, -1)
def test_invalid_constructor_width():
    with pytest.raises(ValueError):
        Rectangle(-5, 10)
Beispiel #22
0
def test_value_1():
    with r(ValueError):
        Rectangle(12, -2)
def test_invalid_constructor_height():
    with pytest.raises(ValueError):
        Rectangle(10, -5)
Beispiel #24
0
def test_simple_1():
    assert Rectangle(2, 3).get_area() == 6
Beispiel #25
0
def test_zero_width_area():
    r = Rectangle(0, 1)
    assert r.get_area() == 0
Beispiel #26
0
def test_type_1():
    with r(TypeError):
        Rectangle(1, '1')
def test_normal_get_perimeter():
    assert Rectangle(4, 10).get_perimeter() == 28