Exemplo n.º 1
0
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
Exemplo n.º 2
0
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")
Exemplo n.º 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)
Exemplo n.º 5
0
Arquivo: app.py Projeto: melnk300/lyc
def test_simple_2():
    assert Rectangle(2, 3).get_perimeter() == 10
Exemplo n.º 6
0
Arquivo: app.py Projeto: melnk300/lyc
def test_value_2():
    with r(ValueError):
        Rectangle(-12, 2)
Exemplo n.º 7
0
Arquivo: app.py Projeto: melnk300/lyc
def test_type_2():
    with r(TypeError):
        Rectangle('s', 1)
Exemplo n.º 8
0
def test_wrong_type():
    with pytest.raises(TypeError):
        r = Rectangle(None, '42')
Exemplo n.º 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')
Exemplo n.º 15
0
def test_zero_width_perimeter():
    r = Rectangle(0, 1)
    assert r.get_perimeter() == 2
Exemplo n.º 16
0
def test_zero_height_perimeter():
    r = Rectangle(1, 0)
    assert r.get_perimeter() == 2
Exemplo n.º 17
0
def test_invalid_type_3():
    with pytest.raises(TypeError):
        Rectangle([], [])
Exemplo n.º 18
0
def test_perimeter():
    r = Rectangle(2, 3)
    assert r.get_perimeter() == 10
Exemplo n.º 19
0
def test_invalid_type_4():
    with pytest.raises(TypeError):
        Rectangle("hi", 4)
Exemplo n.º 20
0
def test_wrong_values():
    with pytest.raises(ValueError):
        r = Rectangle(-1, -1)
Exemplo n.º 21
0
def test_invalid_constructor_width():
    with pytest.raises(ValueError):
        Rectangle(-5, 10)
Exemplo n.º 22
0
Arquivo: app.py Projeto: melnk300/lyc
def test_value_1():
    with r(ValueError):
        Rectangle(12, -2)
Exemplo n.º 23
0
def test_invalid_constructor_height():
    with pytest.raises(ValueError):
        Rectangle(10, -5)
Exemplo n.º 24
0
Arquivo: app.py Projeto: melnk300/lyc
def test_simple_1():
    assert Rectangle(2, 3).get_area() == 6
Exemplo n.º 25
0
def test_zero_width_area():
    r = Rectangle(0, 1)
    assert r.get_area() == 0
Exemplo n.º 26
0
Arquivo: app.py Projeto: melnk300/lyc
def test_type_1():
    with r(TypeError):
        Rectangle(1, '1')
def test_normal_get_perimeter():
    assert Rectangle(4, 10).get_perimeter() == 28