Conditions | 5 |
Total Lines | 103 |
Lines | 0 |
Ratio | 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 | # pylint: disable=redefined-outer-name,unused-argument,unused-variable,singleton-comparison,expression-not-assigned |
||
160 | def describe_update(): |
||
161 | |||
162 | def it_should_not_modify_config(config): |
||
163 | gitman.update('gitman_1', depth=1) |
||
164 | |||
165 | expect(config.__mapper__.text) == CONFIG |
||
166 | |||
167 | def it_should_lock_previously_locked_dependnecies(config): |
||
168 | config.__mapper__.text = strip(""" |
||
169 | location: deps |
||
170 | sources: |
||
171 | - dir: gitman_1 |
||
172 | link: '' |
||
173 | repo: https://github.com/jacebrowning/gitman-demo |
||
174 | rev: example-branch |
||
175 | - dir: gitman_2 |
||
176 | link: '' |
||
177 | repo: https://github.com/jacebrowning/gitman-demo |
||
178 | rev: example-tag |
||
179 | sources_locked: |
||
180 | - dir: gitman_2 |
||
181 | link: '' |
||
182 | repo: https://github.com/jacebrowning/gitman-demo |
||
183 | rev: (old revision) |
||
184 | """) |
||
185 | |||
186 | gitman.update(depth=1) |
||
187 | |||
188 | expect(config.__mapper__.text) == strip(""" |
||
189 | location: deps |
||
190 | sources: |
||
191 | - dir: gitman_1 |
||
192 | link: '' |
||
193 | repo: https://github.com/jacebrowning/gitman-demo |
||
194 | rev: example-branch |
||
195 | - dir: gitman_2 |
||
196 | link: '' |
||
197 | repo: https://github.com/jacebrowning/gitman-demo |
||
198 | rev: example-tag |
||
199 | sources_locked: |
||
200 | - dir: gitman_2 |
||
201 | link: '' |
||
202 | repo: https://github.com/jacebrowning/gitman-demo |
||
203 | rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04 |
||
204 | """) |
||
205 | |||
206 | def it_should_not_lock_dependnecies_when_disabled(config): |
||
207 | config.__mapper__.text = strip(""" |
||
208 | location: deps |
||
209 | sources: |
||
210 | - dir: gitman_1 |
||
211 | link: '' |
||
212 | repo: https://github.com/jacebrowning/gitman-demo |
||
213 | rev: example-branch |
||
214 | - dir: gitman_2 |
||
215 | link: '' |
||
216 | repo: https://github.com/jacebrowning/gitman-demo |
||
217 | rev: example-tag |
||
218 | sources_locked: |
||
219 | - dir: gitman_2 |
||
220 | link: '' |
||
221 | repo: https://github.com/jacebrowning/gitman-demo |
||
222 | rev: (old revision) |
||
223 | """) |
||
224 | |||
225 | gitman.update(depth=1, lock=False) |
||
226 | |||
227 | expect(config.__mapper__.text) == strip(""" |
||
228 | location: deps |
||
229 | sources: |
||
230 | - dir: gitman_1 |
||
231 | link: '' |
||
232 | repo: https://github.com/jacebrowning/gitman-demo |
||
233 | rev: example-branch |
||
234 | - dir: gitman_2 |
||
235 | link: '' |
||
236 | repo: https://github.com/jacebrowning/gitman-demo |
||
237 | rev: example-tag |
||
238 | sources_locked: |
||
239 | - dir: gitman_2 |
||
240 | link: '' |
||
241 | repo: https://github.com/jacebrowning/gitman-demo |
||
242 | rev: (old revision) |
||
243 | """) |
||
244 | |||
245 | def it_should_lock_all_when_enabled(config): |
||
246 | gitman.update(depth=1, lock=True) |
||
247 | |||
248 | expect(config.__mapper__.text) == CONFIG + strip(""" |
||
249 | sources_locked: |
||
250 | - dir: gitman_1 |
||
251 | link: '' |
||
252 | repo: https://github.com/jacebrowning/gitman-demo |
||
253 | rev: eb37743011a398b208dd9f9ef79a408c0fc10d48 |
||
254 | - dir: gitman_2 |
||
255 | link: '' |
||
256 | repo: https://github.com/jacebrowning/gitman-demo |
||
257 | rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04 |
||
258 | - dir: gitman_3 |
||
259 | link: '' |
||
260 | repo: https://github.com/jacebrowning/gitman-demo |
||
261 | rev: 9bf18e16b956041f0267c21baad555a23237b52e |
||
262 | """) |
||
263 | |||
310 |