| Conditions | 2 |
| Total Lines | 55 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 | import py |
||
| 68 | @pytest.mark.parametrize('args', ['compare --help', 'help compare']) |
||
| 69 | def test_help_compare(testdir, args): |
||
| 70 | result = testdir.run('py.test-benchmark', *args.split()) |
||
| 71 | result.stdout.fnmatch_lines([ |
||
| 72 | "usage: py.test-benchmark compare [-h] [--sort COL] [--group-by LABEL]", |
||
| 73 | " [--columns LABELS] [--name FORMAT]", |
||
| 74 | " [--histogram [FILENAME-PREFIX]]", |
||
| 75 | " [--csv [FILENAME]]", |
||
| 76 | " [glob_or_file [glob_or_file ...]]", |
||
| 77 | "", |
||
| 78 | "Compare saved runs.", |
||
| 79 | "", |
||
| 80 | "positional arguments:", |
||
| 81 | " glob_or_file Glob or exact path for json files. If not specified", |
||
| 82 | " all runs are loaded.", |
||
| 83 | "", |
||
| 84 | "optional arguments:", |
||
| 85 | " -h, --help show this help message and exit", |
||
| 86 | " --sort COL Column to sort on. Can be one of: 'min', 'max',", |
||
| 87 | " 'mean', 'stddev', 'name', 'fullname'. Default: 'min'", |
||
| 88 | " --group-by LABEL How to group tests. Can be one of: 'group', 'name',", |
||
| 89 | " 'fullname', 'func', 'fullfunc', 'param' or", |
||
| 90 | " 'param:NAME', where NAME is the name passed to", |
||
| 91 | " @pytest.parametrize. Default: 'group'", |
||
| 92 | " --columns LABELS Comma-separated list of columns to show in the result", |
||
| 93 | " table. Default: 'min, max, mean, stddev, median, iqr,", |
||
| 94 | " outliers, rounds, iterations'", |
||
| 95 | " --name FORMAT How to format names in results. Can be one of 'short',", |
||
| 96 | " 'normal', 'long'. Default: 'normal'", |
||
| 97 | " --histogram [FILENAME-PREFIX]", |
||
| 98 | " Plot graphs of min/max/avg/stddev over time in", |
||
| 99 | " FILENAME-PREFIX-test_name.svg. If FILENAME-PREFIX", |
||
| 100 | " contains slashes ('/') then directories will be", |
||
| 101 | " created. Default: 'benchmark_*'", |
||
| 102 | " --csv [FILENAME] Save a csv report. If FILENAME contains slashes ('/')", |
||
| 103 | " then directories will be created. Default:", |
||
| 104 | " 'benchmark_*'", |
||
| 105 | "", |
||
| 106 | "examples:", |
||
| 107 | "", |
||
| 108 | " pytest-benchmark compare 'Linux-CPython-3.5-64bit/*'", |
||
| 109 | "", |
||
| 110 | " Loads all benchmarks ran with that interpreter. Note the special quoting that disables your shell's " |
||
| 111 | "glob", |
||
| 112 | " expansion.", |
||
| 113 | "", |
||
| 114 | " pytest-benchmark compare 0001", |
||
| 115 | "", |
||
| 116 | " Loads first run from all the interpreters.", |
||
| 117 | "", |
||
| 118 | " pytest-benchmark compare /foo/bar/0001_abc.json /lorem/ipsum/0001_sir_dolor.json", |
||
| 119 | "", |
||
| 120 | " Loads runs from exactly those files.", |
||
| 121 | ]) |
||
| 122 | assert result.ret == 0 |
||
| 123 | |||
| 194 |