def test_rect_add_square(a, b, fig_obj): rect = Rectangle(a, b) if fig_obj == 'Square': fig = Square(5) assert rect.add_square(fig) == a * b + fig.get_area( ), 'Cannot calculate square of figures: rectangle & square!' elif fig_obj == 'Rectangle': fig = Rectangle(5, 3) assert rect.add_square(fig) == a * b + fig.get_area( ), 'Cannot calculate square of figures: rectangle & rectangle!' elif fig_obj == 'Cyrcle': fig = Cyrcle(4) assert rect.add_square(fig) == a * b + fig.get_area( ), 'Cannot calculate square of figures: rectangle & cyrcle!' elif fig_obj == 'Triangle': fig = Triangle(3, 5, 7) assert rect.add_square(fig) == a * b + fig.get_area( ), 'Cannot calculate square of figures: rectangle & triangle!'
def test_square_add_square(a, fig_obj): sq = Square(a) if fig_obj == 'Square': fig = Square(5) assert sq.add_square(fig) == a**2 + fig.get_area( ), 'Cannot calculate square of figures: square & square!' elif fig_obj == 'Rectangle': fig = Rectangle(5, 3) assert sq.add_square(fig) == a**2 + fig.get_area( ), 'Cannot calculate square of figures: square & rectangle!' elif fig_obj == 'Cyrcle': fig = Cyrcle(4) assert sq.add_square(fig) == a**2 + fig.get_area( ), 'Cannot calculate square of figures: square & cyrcle!' elif fig_obj == 'Triangle': fig = Triangle(3, 5, 7) assert sq.add_square(fig) == a**2 + fig.get_area( ), 'Cannot calculate square of figures: square & triangle!'
def test_cyrcle_has_attr_name(a): cyr = Cyrcle(a) assert cyr.name == 'Cyrcle', 'Name is incorrect!'
def test_cyrcle_add_square(a, fig_obj): cyr = Cyrcle(a) if fig_obj == 'Square': fig = Square(5) assert cyr.add_square(fig) == round(cyr.get_area() + fig.get_area(), 3), \ 'Cannot calculate square of figures: cyrcle & square!' elif fig_obj == 'Rectangle': fig = Rectangle(5, 3) assert cyr.add_square(fig) == round(cyr.get_area() + fig.get_area(), 3), \ 'Cannot calculate square of figures: cyrcle & rectangle!' elif fig_obj == 'Cyrcle': fig = Cyrcle(4) assert cyr.add_square(fig) == round(cyr.get_area() + fig.get_area(), 3), \ 'Cannot calculate square of figures: cyrcle & cyrcle!' elif fig_obj == 'Triangle': fig = Triangle(3, 5, 7) assert cyr.add_square(fig) == round(cyr.get_area()+fig.get_area(), 3), \ 'Cannot calculate square of figures: cyrcle & triangle!'
def test_cyrcle_get_perimeter(a): cyr = Cyrcle(a) assert cyr.get_perimeter() == 2 * math.pi * a
def test_cyrcle_get_angles(a): cyr = Cyrcle(a) assert cyr.get_angles() == 0, 'Count of angles is incorrect!'
def test_cyrcle_get_area(a): cyr = Cyrcle(a) assert cyr.get_area() == round(math.pi * a**2, 3), 'Area is incorrect!'