Conditions | 1 |
Total Lines | 181 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | """Module for testing grouped optimizer.""" |
||
33 | def test_calling_functions(self): |
||
34 | """Test correct order of calling function.""" |
||
35 | optimizer = GroupedOptimizer(TESTED_PROCESS, GROUPING_STRATEGY, |
||
36 | PSO_ALGORITHM) |
||
37 | expected_calls = [call.method_name('0', '__init__'), |
||
38 | call.method_name('1', '__init__'), |
||
39 | call.method_name('2', '__init__'), |
||
40 | call.method_name('3', '__init__'), |
||
41 | call.method_name('4', '__init__'), |
||
42 | call.method_name('5', '__init__'), |
||
43 | call.method_name('6', '__init__'), |
||
44 | call.method_name('0', 'get_output_of_stage', 1), |
||
45 | call.method_name('1', 'get_output_of_stage', 1), |
||
46 | call.method_name('2', 'get_output_of_stage', 1), |
||
47 | call.method_name('0', 'get_quality', 1), |
||
48 | call.method_name('1', 'get_quality', 1), |
||
49 | call.method_name('2', 'get_quality', 1), |
||
50 | call.method_name('0', 'is_enough_quality', 1), |
||
51 | call.method_name('0', 'could_be_optimized', 1), |
||
52 | call.method_name('1', 'is_enough_quality', 1), |
||
53 | call.method_name('1', 'could_be_optimized', 1), |
||
54 | call.method_name('2', 'is_enough_quality', 1), |
||
55 | call.method_name('2', 'could_be_optimized', 1), |
||
56 | call.method_name('0', 'get_output_of_stage', 2), |
||
57 | call.method_name('1', 'get_output_of_stage', 2), |
||
58 | call.method_name('2', 'get_output_of_stage', 2), |
||
59 | call.method_name('0', 'get_quality', 2), |
||
60 | call.method_name('1', 'get_quality', 2), |
||
61 | call.method_name('2', 'get_quality', 2), |
||
62 | call.method_name('0', 'is_enough_quality', 2), |
||
63 | call.method_name('0', 'could_be_optimized', 2), |
||
64 | call.method_name('1', 'is_enough_quality', 2), |
||
65 | call.method_name('1', 'could_be_optimized', 2), |
||
66 | call.method_name('2', 'is_enough_quality', 2), |
||
67 | call.method_name('2', 'could_be_optimized', 2), |
||
68 | call.method_name('0', 'get_output_of_stage', 3), |
||
69 | call.method_name('1', 'get_output_of_stage', 3), |
||
70 | call.method_name('2', 'get_output_of_stage', 3), |
||
71 | call.method_name('0', 'get_quality', 3), |
||
72 | call.method_name('1', 'get_quality', 3), |
||
73 | call.method_name('2', 'get_quality', 3), |
||
74 | call.method_name('0', 'is_enough_quality', 3), |
||
75 | call.method_name('0', 'could_be_optimized', 3), |
||
76 | call.method_name('1', 'is_enough_quality', 3), |
||
77 | call.method_name('1', 'could_be_optimized', 3), |
||
78 | call.method_name('2', 'is_enough_quality', 3), |
||
79 | call.method_name('2', 'could_be_optimized', 3), |
||
80 | call.method_name('0', 'get_output_of_stage', 4), |
||
81 | call.method_name('1', 'get_output_of_stage', 4), |
||
82 | call.method_name('2', 'get_output_of_stage', 4), |
||
83 | call.method_name('0', 'get_quality', 4), |
||
84 | call.method_name('1', 'get_quality', 4), |
||
85 | call.method_name('2', 'get_quality', 4), |
||
86 | call.method_name('0', 'is_enough_quality', 4), |
||
87 | call.method_name('0', 'could_be_optimized', 4), |
||
88 | call.method_name('1', 'is_enough_quality', 4), |
||
89 | call.method_name('1', 'could_be_optimized', 4), |
||
90 | call.method_name('2', 'is_enough_quality', 4), |
||
91 | call.method_name('2', 'could_be_optimized', 4), |
||
92 | call.method_name('0', 'get_output_of_stage', 5), |
||
93 | call.method_name('1', 'get_output_of_stage', 5), |
||
94 | call.method_name('2', 'get_output_of_stage', 5), |
||
95 | call.method_name('0', 'get_quality', 5), |
||
96 | call.method_name('1', 'get_quality', 5), |
||
97 | call.method_name('2', 'get_quality', 5), |
||
98 | call.method_name('0', 'is_enough_quality', 5), |
||
99 | call.method_name('0', 'could_be_optimized', 5), |
||
100 | call.method_name('1', 'is_enough_quality', 5), |
||
101 | call.method_name('1', 'could_be_optimized', 5), |
||
102 | call.method_name('2', 'is_enough_quality', 5), |
||
103 | call.method_name('2', 'could_be_optimized', 5), |
||
104 | call.method_name('0', 'get_output_of_stage', 6), |
||
105 | call.method_name('1', 'get_output_of_stage', 6), |
||
106 | call.method_name('2', 'get_output_of_stage', 6), |
||
107 | call.method_name('0', 'get_quality', 6), |
||
108 | call.method_name('1', 'get_quality', 6), |
||
109 | call.method_name('2', 'get_quality', 6), |
||
110 | call.method_name('0', 'is_enough_quality', 6), |
||
111 | call.method_name('0', 'could_be_optimized', 6), |
||
112 | call.method_name('1', 'is_enough_quality', 6), |
||
113 | call.method_name('1', 'could_be_optimized', 6), |
||
114 | call.method_name('2', 'is_enough_quality', 6), |
||
115 | call.method_name('2', 'could_be_optimized', 6), |
||
116 | call.method_name('3', 'get_output_of_stage', 1), |
||
117 | call.method_name('4', 'get_output_of_stage', 1), |
||
118 | call.method_name('5', 'get_output_of_stage', 1), |
||
119 | call.method_name('3', 'get_quality', 1), |
||
120 | call.method_name('4', 'get_quality', 1), |
||
121 | call.method_name('5', 'get_quality', 1), |
||
122 | call.method_name('3', 'is_enough_quality', 1), |
||
123 | call.method_name('3', 'could_be_optimized', 1), |
||
124 | call.method_name('4', 'is_enough_quality', 1), |
||
125 | call.method_name('4', 'could_be_optimized', 1), |
||
126 | call.method_name('5', 'is_enough_quality', 1), |
||
127 | call.method_name('5', 'could_be_optimized', 1), |
||
128 | call.method_name('3', 'get_output_of_stage', 2), |
||
129 | call.method_name('4', 'get_output_of_stage', 2), |
||
130 | call.method_name('5', 'get_output_of_stage', 2), |
||
131 | call.method_name('3', 'get_quality', 2), |
||
132 | call.method_name('4', 'get_quality', 2), |
||
133 | call.method_name('5', 'get_quality', 2), |
||
134 | call.method_name('3', 'is_enough_quality', 2), |
||
135 | call.method_name('3', 'could_be_optimized', 2), |
||
136 | call.method_name('4', 'is_enough_quality', 2), |
||
137 | call.method_name('4', 'could_be_optimized', 2), |
||
138 | call.method_name('5', 'is_enough_quality', 2), |
||
139 | call.method_name('5', 'could_be_optimized', 2), |
||
140 | call.method_name('3', 'get_output_of_stage', 3), |
||
141 | call.method_name('4', 'get_output_of_stage', 3), |
||
142 | call.method_name('5', 'get_output_of_stage', 3), |
||
143 | call.method_name('3', 'get_quality', 3), |
||
144 | call.method_name('4', 'get_quality', 3), |
||
145 | call.method_name('5', 'get_quality', 3), |
||
146 | call.method_name('3', 'is_enough_quality', 3), |
||
147 | call.method_name('3', 'could_be_optimized', 3), |
||
148 | call.method_name('4', 'is_enough_quality', 3), |
||
149 | call.method_name('4', 'could_be_optimized', 3), |
||
150 | call.method_name('5', 'is_enough_quality', 3), |
||
151 | call.method_name('5', 'could_be_optimized', 3), |
||
152 | call.method_name('3', 'get_output_of_stage', 4), |
||
153 | call.method_name('4', 'get_output_of_stage', 4), |
||
154 | call.method_name('5', 'get_output_of_stage', 4), |
||
155 | call.method_name('3', 'get_quality', 4), |
||
156 | call.method_name('4', 'get_quality', 4), |
||
157 | call.method_name('5', 'get_quality', 4), |
||
158 | call.method_name('3', 'is_enough_quality', 4), |
||
159 | call.method_name('3', 'could_be_optimized', 4), |
||
160 | call.method_name('4', 'is_enough_quality', 4), |
||
161 | call.method_name('4', 'could_be_optimized', 4), |
||
162 | call.method_name('5', 'is_enough_quality', 4), |
||
163 | call.method_name('5', 'could_be_optimized', 4), |
||
164 | call.method_name('3', 'get_output_of_stage', 5), |
||
165 | call.method_name('4', 'get_output_of_stage', 5), |
||
166 | call.method_name('5', 'get_output_of_stage', 5), |
||
167 | call.method_name('3', 'get_quality', 5), |
||
168 | call.method_name('4', 'get_quality', 5), |
||
169 | call.method_name('5', 'get_quality', 5), |
||
170 | call.method_name('3', 'is_enough_quality', 5), |
||
171 | call.method_name('3', 'could_be_optimized', 5), |
||
172 | call.method_name('4', 'is_enough_quality', 5), |
||
173 | call.method_name('4', 'could_be_optimized', 5), |
||
174 | call.method_name('5', 'is_enough_quality', 5), |
||
175 | call.method_name('5', 'could_be_optimized', 5), |
||
176 | call.method_name('3', 'get_output_of_stage', 6), |
||
177 | call.method_name('4', 'get_output_of_stage', 6), |
||
178 | call.method_name('5', 'get_output_of_stage', 6), |
||
179 | call.method_name('3', 'get_quality', 6), |
||
180 | call.method_name('4', 'get_quality', 6), |
||
181 | call.method_name('5', 'get_quality', 6), |
||
182 | call.method_name('3', 'is_enough_quality', 6), |
||
183 | call.method_name('3', 'could_be_optimized', 6), |
||
184 | call.method_name('4', 'is_enough_quality', 6), |
||
185 | call.method_name('4', 'could_be_optimized', 6), |
||
186 | call.method_name('5', 'is_enough_quality', 6), |
||
187 | call.method_name('5', 'could_be_optimized', 6), |
||
188 | call.method_name('6', 'get_output_of_stage', 1), |
||
189 | call.method_name('6', 'get_quality', 1), |
||
190 | call.method_name('6', 'is_enough_quality', 1), |
||
191 | call.method_name('6', 'could_be_optimized', 1), |
||
192 | call.method_name('6', 'get_output_of_stage', 2), |
||
193 | call.method_name('6', 'get_quality', 2), |
||
194 | call.method_name('6', 'is_enough_quality', 2), |
||
195 | call.method_name('6', 'could_be_optimized', 2), |
||
196 | call.method_name('6', 'get_output_of_stage', 3), |
||
197 | call.method_name('6', 'get_quality', 3), |
||
198 | call.method_name('6', 'is_enough_quality', 3), |
||
199 | call.method_name('6', 'could_be_optimized', 3), |
||
200 | call.method_name('6', 'get_output_of_stage', 4), |
||
201 | call.method_name('6', 'get_quality', 4), |
||
202 | call.method_name('6', 'is_enough_quality', 4), |
||
203 | call.method_name('6', 'could_be_optimized', 4), |
||
204 | call.method_name('6', 'get_output_of_stage', 5), |
||
205 | call.method_name('6', 'get_quality', 5), |
||
206 | call.method_name('6', 'is_enough_quality', 5), |
||
207 | call.method_name('6', 'could_be_optimized', 5), |
||
208 | call.method_name('6', 'get_output_of_stage', 6), |
||
209 | call.method_name('6', 'get_quality', 6), |
||
210 | call.method_name('6', 'is_enough_quality', 6), |
||
211 | call.method_name('6', 'could_be_optimized', 6)] |
||
212 | optimizer.optimize_process() |
||
213 | self.assertListEqual(CALLS_COUNTER.method_calls, expected_calls) |
||
214 | |||
312 |
This check looks for calls to members that are non-existent. These calls will fail.
The member could have been renamed or removed.