def test_two_negative_sides(self): with pytest.raises(Exception) as excinfo: a = figures.Cuboid(1, -2, -3) assert str(excinfo.value) == "Side can not be less than zero"
def test_negative_side_and_zero_side(self): with pytest.raises(Exception) as excinfo: a = figures.Cuboid(-1, 0, 1) assert str(excinfo.value) == "Side can not be less than zero"
def test_two_sides_equal_0(self): a = figures.Cuboid(1, 0, 0) assert a.get_area() == 0 assert a.get_perimeter() == 0 assert a.get_volume() == 0
def test_side_is_float(self): a = figures.Cuboid(0.25, 1, 4) assert a.get_area() == 10.5 assert a.get_perimeter() == 21 assert a.get_volume() == 1
def test_sides_equal_1_3(self): a = figures.Cuboid(1, 2, 3) assert a.get_area() == 22 assert a.get_perimeter() == 24 assert a.get_volume() == 6
def test_sides_equal_2_2(self): a = figures.Cuboid(2, 2, 2) assert a.get_area() == 24 assert a.get_perimeter() == 24 assert a.get_volume() == 8
def test_side_equal_1(self): a = figures.Cuboid(1) assert a.get_area() == 6 assert a.get_perimeter() == 12 assert a.get_volume() == 1
def test_init_without_parameters(self): a = figures.Cuboid() assert a.get_area() == 6 assert a.get_perimeter() == 12 assert a.get_volume() == 1
import figures circle = figures.Circle(3) square = figures.Square(2) rectangle = figures.Rectangle(2, 4) for third_dimension_figure in [circle, square, rectangle]: print( f'Area of {type(third_dimension_figure).__name__} = {third_dimension_figure.get_area()}' ) print( f'Perimeter of {type(third_dimension_figure).__name__} = {third_dimension_figure.get_perimeter()}' ) print() sphere = figures.Sphere(3) cube = figures.Cube(3) cuboid = figures.Cuboid(2, 4, 5) for third_dimension_figure in [sphere, cube, cuboid]: print( f'Area of {type(third_dimension_figure).__name__} = {third_dimension_figure.get_area()}' ) print( f'Perimeter of {type(third_dimension_figure).__name__} = {third_dimension_figure.get_perimeter()}' ) print( f'Volume of {type(third_dimension_figure).__name__} = {third_dimension_figure.get_volume()}' ) print()