Conditions | 9 |
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=no-self-use,redefined-outer-name,unused-variable,unused-argument |
||
136 | def describe_update(): |
||
137 | |||
138 | def it_should_not_modify_config(config): |
||
139 | gdm.update('gdm_1', depth=1) |
||
140 | |||
141 | assert CONFIG == config.__mapper__.text |
||
142 | |||
143 | def it_should_lock_previously_locked_dependnecies(config): |
||
144 | config.__mapper__.text = strip(""" |
||
145 | location: deps |
||
146 | sources: |
||
147 | - dir: gdm_1 |
||
148 | link: '' |
||
149 | repo: https://github.com/jacebrowning/gdm-demo |
||
150 | rev: example-branch |
||
151 | - dir: gdm_2 |
||
152 | link: '' |
||
153 | repo: https://github.com/jacebrowning/gdm-demo |
||
154 | rev: example-tag |
||
155 | sources_locked: |
||
156 | - dir: gdm_2 |
||
157 | link: '' |
||
158 | repo: https://github.com/jacebrowning/gdm-demo |
||
159 | rev: (old revision) |
||
160 | """) |
||
161 | |||
162 | gdm.update(depth=1) |
||
163 | |||
164 | assert strip(""" |
||
165 | location: deps |
||
166 | sources: |
||
167 | - dir: gdm_1 |
||
168 | link: '' |
||
169 | repo: https://github.com/jacebrowning/gdm-demo |
||
170 | rev: example-branch |
||
171 | - dir: gdm_2 |
||
172 | link: '' |
||
173 | repo: https://github.com/jacebrowning/gdm-demo |
||
174 | rev: example-tag |
||
175 | sources_locked: |
||
176 | - dir: gdm_2 |
||
177 | link: '' |
||
178 | repo: https://github.com/jacebrowning/gdm-demo |
||
179 | rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04 |
||
180 | """) == config.__mapper__.text |
||
181 | |||
182 | def it_should_not_lock_dependnecies_when_disabled(config): |
||
183 | config.__mapper__.text = strip(""" |
||
184 | location: deps |
||
185 | sources: |
||
186 | - dir: gdm_1 |
||
187 | link: '' |
||
188 | repo: https://github.com/jacebrowning/gdm-demo |
||
189 | rev: example-branch |
||
190 | - dir: gdm_2 |
||
191 | link: '' |
||
192 | repo: https://github.com/jacebrowning/gdm-demo |
||
193 | rev: example-tag |
||
194 | sources_locked: |
||
195 | - dir: gdm_2 |
||
196 | link: '' |
||
197 | repo: https://github.com/jacebrowning/gdm-demo |
||
198 | rev: (old revision) |
||
199 | """) |
||
200 | |||
201 | gdm.update(depth=1, lock=False) |
||
202 | |||
203 | assert strip(""" |
||
204 | location: deps |
||
205 | sources: |
||
206 | - dir: gdm_1 |
||
207 | link: '' |
||
208 | repo: https://github.com/jacebrowning/gdm-demo |
||
209 | rev: example-branch |
||
210 | - dir: gdm_2 |
||
211 | link: '' |
||
212 | repo: https://github.com/jacebrowning/gdm-demo |
||
213 | rev: example-tag |
||
214 | sources_locked: |
||
215 | - dir: gdm_2 |
||
216 | link: '' |
||
217 | repo: https://github.com/jacebrowning/gdm-demo |
||
218 | rev: (old revision) |
||
219 | """) == config.__mapper__.text |
||
220 | |||
221 | def it_should_lock_all_when_enabled(config): |
||
222 | gdm.update(depth=1, lock=True) |
||
223 | |||
224 | assert CONFIG + strip(""" |
||
225 | sources_locked: |
||
226 | - dir: gdm_1 |
||
227 | link: '' |
||
228 | repo: https://github.com/jacebrowning/gdm-demo |
||
229 | rev: eb37743011a398b208dd9f9ef79a408c0fc10d48 |
||
230 | - dir: gdm_2 |
||
231 | link: '' |
||
232 | repo: https://github.com/jacebrowning/gdm-demo |
||
233 | rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04 |
||
234 | - dir: gdm_3 |
||
235 | link: '' |
||
236 | repo: https://github.com/jacebrowning/gdm-demo |
||
237 | rev: 9bf18e16b956041f0267c21baad555a23237b52e |
||
238 | """) == config.__mapper__.text |
||
239 | |||
286 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.