-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_oop.py
107 lines (70 loc) · 3.16 KB
/
test_oop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import pytest
import OOP
@pytest.fixture
def triangle():
return OOP.Triangle(3, 4, 5)
@pytest.fixture
def rectangle():
return OOP.Rectangle(5, 4)
@pytest.fixture
def square():
return OOP.Square(4)
@pytest.fixture
def circle():
return OOP.Circle(20)
# Тестовый класс проверки инстансов классов
class Testclass_instanse:
def test_inst_triangle(self, triangle):
assert isinstance(triangle, OOP.Figure)
def test_inst_rectangle(self, rectangle):
assert isinstance(rectangle, OOP.Figure)
def test_inst_square(self, square):
assert isinstance(square, OOP.Figure)
def test_inst_circle(self, circle):
assert isinstance(circle, OOP.Figure)
# Тестовый класс проверки рассчета периметра фигур
class Testclass_perimeter:
def test_triangle_perimeter(self, triangle):
assert int(triangle.get_perimeter()) == 12
def test_rectangle_perimeter(self, rectangle):
assert rectangle.get_perimeter() == 18
def test_square_perimeter(self, square):
assert square.get_perimeter() == 16
def test_circle_perimeter(self, circle):
assert int(circle.get_perimeter()) == 125
# Тестовый класс проверки рассчета площадей фигур
class Testclass_area:
def test_triangle_area(self, triangle):
assert int(triangle.get_area()) == 6
def test_rectangle_area(self, rectangle):
assert rectangle.get_area() == 20
def test_square_area(self, square):
assert square.get_area() == 16
def test_circle_area(self, circle):
assert int(circle.get_area()) == 1256
# Тестовый класс проверки суммирования площадей фигур
class Testclass_add_area:
def test_triangle_plus_rectangle(self, triangle, rectangle):
assert triangle.add_area(rectangle) == 26
def test_triangle_plus_square(self, triangle, square):
assert triangle.add_area(square) == 22
def test_triangle_plus_circle(self, triangle, circle):
assert triangle.add_area(circle) == 1262.6370614359173
def test_rectangle_plus_triangle(self, rectangle, triangle):
assert rectangle.add_area(triangle) == 26
def test_rectangle_plus_square(self, rectangle, square):
assert rectangle.add_area(square) == 36
def test_rectangle_plus_circle(self, rectangle, circle):
assert rectangle.add_area(circle) == 1276.6370614359173
def test_square_plus_triangle(self, square, triangle):
assert square.add_area(triangle) == 22
def test_square_plus_rectangle(self, square, rectangle):
assert square.add_area(rectangle) == 36
def test_square_plus_circle(self, square, circle):
assert square.add_area(circle) == 1272.6370614359173
def test_circle_plus_triangle(self, circle, triangle):
assert circle.add_area(triangle) == 1262.6370614359173
def test_circle_plus_rectangle(self, circle, rectangle):
assert circle.add_area(rectangle) == 1276.6370614359173
def test_circle_plus_square(self, circle, square):
assert circle.add_area(square) == 1272.6370614359173