| Conditions | 1 |
| Total Lines | 51 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 | # -*- coding: utf-8 -*- |
||
| 120 | def describe_cli(): |
||
| 121 | |||
| 122 | def it_displays_help_information(cli): |
||
| 123 | cmd = cli('--help') |
||
| 124 | |||
| 125 | expect(cmd.returncode) == 0 |
||
| 126 | expect(cmd.stdout).contains("usage: verchew") |
||
| 127 | |||
| 128 | def it_displays_version_information(cli): |
||
| 129 | cmd = cli('--version') |
||
| 130 | |||
| 131 | expect(cmd.returncode) == 0 |
||
| 132 | expect(cmd.stdout or cmd.stderr).contains("verchew v1.") |
||
| 133 | |||
| 134 | def it_generates_a_sample_config(cli): |
||
| 135 | cmd = cli('--init') |
||
| 136 | |||
| 137 | expect(cmd.returncode) == 0 |
||
| 138 | expect(cmd.stderr) == "" |
||
| 139 | expect(cmd.stdout).contains("Checking for Make") |
||
| 140 | |||
| 141 | @pytest.mark.skipif(sys.platform == 'win32', reason="unix only") |
||
| 142 | @pytest.mark.skipif(sys.version_info[0] == 2, reason="python3 only") |
||
| 143 | def it_displays_results_on_unix_python_3(cli): |
||
| 144 | cmd = cli('--root', EXAMPLES_DIR) |
||
| 145 | |||
| 146 | expect(cmd.returncode) == 0 |
||
| 147 | expect(cmd.stderr) == "" |
||
| 148 | expect(cmd.stdout) == STYLED_OUTPUT |
||
| 149 | |||
| 150 | @pytest.mark.skipif(sys.platform == 'win32', reason="unix only") |
||
| 151 | @pytest.mark.skipif(sys.version_info[0] == 3, reason="python2 only") |
||
| 152 | def it_displays_results_on_unix_python_2(cli): |
||
| 153 | cmd = cli('--root', EXAMPLES_DIR) |
||
| 154 | |||
| 155 | expect(cmd.returncode) == 0 |
||
| 156 | expect(cmd.stderr) == "" |
||
| 157 | expect(cmd.stdout) == UNSTYLED_OUTPUT |
||
| 158 | |||
| 159 | @pytest.mark.skipif(sys.platform != 'win32', reason="windows only") |
||
| 160 | def it_displays_results_on_windows(cli): |
||
| 161 | cmd = cli('--root', EXAMPLES_DIR) |
||
| 162 | |||
| 163 | expect(cmd.returncode) == 0 |
||
| 164 | expect(cmd.stderr) == "" |
||
| 165 | expect(cmd.stdout) == UNSTYLED_OUTPUT_WINDOWS |
||
| 166 | |||
| 167 | def it_exits_with_an_error_code_if_enabled(cli): |
||
| 168 | cmd = cli('--root', EXAMPLES_DIR, '--exit-code') |
||
| 169 | |||
| 170 | expect(cmd.returncode) == 1 |
||
| 171 |