Skip to content

Commit e54c6a1

Browse files
authored
Document the --code-highlight default (pytest-dev#9883)
Also normalized all help text using the patterns: * `One sentence help text` * `First sentence of help. Second sentence of help.`
1 parent 9a8f5dd commit e54c6a1

28 files changed

+279
-272
lines changed

changelog/9883.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Normalize the help description of all command-line options.

doc/en/reference/reference.rst

Lines changed: 141 additions & 141 deletions
Large diffs are not rendered by default.

src/_pytest/assertion/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def pytest_addoption(parser: Parser) -> None:
3939
"enable_assertion_pass_hook",
4040
type="bool",
4141
default=False,
42-
help="Enables the pytest_assertion_pass hook."
42+
help="Enables the pytest_assertion_pass hook. "
4343
"Make sure to delete any previously generated pyc cache files.",
4444
)
4545

src/_pytest/cacheprovider.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,15 @@ def pytest_addoption(parser: Parser) -> None:
440440
"--last-failed",
441441
action="store_true",
442442
dest="lf",
443-
help="rerun only the tests that failed "
443+
help="Rerun only the tests that failed "
444444
"at the last run (or all if none failed)",
445445
)
446446
group.addoption(
447447
"--ff",
448448
"--failed-first",
449449
action="store_true",
450450
dest="failedfirst",
451-
help="run all tests, but run the last failures first.\n"
451+
help="Run all tests, but run the last failures first. "
452452
"This may re-order tests and thus lead to "
453453
"repeated fixture setup/teardown.",
454454
)
@@ -457,7 +457,7 @@ def pytest_addoption(parser: Parser) -> None:
457457
"--new-first",
458458
action="store_true",
459459
dest="newfirst",
460-
help="run tests from new files first, then the rest of the tests "
460+
help="Run tests from new files first, then the rest of the tests "
461461
"sorted by file mtime",
462462
)
463463
group.addoption(
@@ -466,28 +466,28 @@ def pytest_addoption(parser: Parser) -> None:
466466
nargs="?",
467467
dest="cacheshow",
468468
help=(
469-
"show cache contents, don't perform collection or tests. "
469+
"Show cache contents, don't perform collection or tests. "
470470
"Optional argument: glob (default: '*')."
471471
),
472472
)
473473
group.addoption(
474474
"--cache-clear",
475475
action="store_true",
476476
dest="cacheclear",
477-
help="remove all cache contents at start of test run.",
477+
help="Remove all cache contents at start of test run",
478478
)
479479
cache_dir_default = ".pytest_cache"
480480
if "TOX_ENV_DIR" in os.environ:
481481
cache_dir_default = os.path.join(os.environ["TOX_ENV_DIR"], cache_dir_default)
482-
parser.addini("cache_dir", default=cache_dir_default, help="cache directory path.")
482+
parser.addini("cache_dir", default=cache_dir_default, help="Cache directory path")
483483
group.addoption(
484484
"--lfnf",
485485
"--last-failed-no-failures",
486486
action="store",
487487
dest="last_failed_no_failures",
488488
choices=("all", "none"),
489489
default="all",
490-
help="which tests to run with no previously (known) failures.",
490+
help="Which tests to run with no previously (known) failures",
491491
)
492492

493493

src/_pytest/capture.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def pytest_addoption(parser: Parser) -> None:
4242
default="fd",
4343
metavar="method",
4444
choices=["fd", "sys", "no", "tee-sys"],
45-
help="per-test capturing method: one of fd|sys|no|tee-sys.",
45+
help="Per-test capturing method: one of fd|sys|no|tee-sys",
4646
)
4747
group._addoption(
4848
"-s",
4949
action="store_const",
5050
const="no",
5151
dest="capture",
52-
help="shortcut for --capture=no.",
52+
help="Shortcut for --capture=no",
5353
)
5454

5555

src/_pytest/config/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,11 @@ def _initini(self, args: Sequence[str]) -> None:
11151115
self.inicfg = inicfg
11161116
self._parser.extra_info["rootdir"] = str(self.rootpath)
11171117
self._parser.extra_info["inifile"] = str(self.inipath)
1118-
self._parser.addini("addopts", "extra command line options", "args")
1119-
self._parser.addini("minversion", "minimally required pytest version")
1118+
self._parser.addini("addopts", "Extra command line options", "args")
1119+
self._parser.addini("minversion", "Minimally required pytest version")
11201120
self._parser.addini(
11211121
"required_plugins",
1122-
"plugins that must be present for pytest to run",
1122+
"Plugins that must be present for pytest to run",
11231123
type="args",
11241124
default=[],
11251125
)

src/_pytest/config/argparsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
_ispytest: bool = False,
4949
) -> None:
5050
check_ispytest(_ispytest)
51-
self._anonymous = OptionGroup("custom options", parser=self, _ispytest=True)
51+
self._anonymous = OptionGroup("Custom options", parser=self, _ispytest=True)
5252
self._groups: List[OptionGroup] = []
5353
self._processopt = processopt
5454
self._usage = usage

src/_pytest/debugging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ def pytest_addoption(parser: Parser) -> None:
4646
"--pdb",
4747
dest="usepdb",
4848
action="store_true",
49-
help="start the interactive Python debugger on errors or KeyboardInterrupt.",
49+
help="Start the interactive Python debugger on errors or KeyboardInterrupt",
5050
)
5151
group._addoption(
5252
"--pdbcls",
5353
dest="usepdb_cls",
5454
metavar="modulename:classname",
5555
type=_validate_usepdb_cls,
56-
help="specify a custom interactive Python debugger for use with --pdb."
56+
help="Specify a custom interactive Python debugger for use with --pdb."
5757
"For example: --pdbcls=IPython.terminal.debugger:TerminalPdb",
5858
)
5959
group._addoption(
6060
"--trace",
6161
dest="trace",
6262
action="store_true",
63-
help="Immediately break when running each test.",
63+
help="Immediately break when running each test",
6464
)
6565

6666

src/_pytest/doctest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,26 @@
6666
def pytest_addoption(parser: Parser) -> None:
6767
parser.addini(
6868
"doctest_optionflags",
69-
"option flags for doctests",
69+
"Option flags for doctests",
7070
type="args",
7171
default=["ELLIPSIS"],
7272
)
7373
parser.addini(
74-
"doctest_encoding", "encoding used for doctest files", default="utf-8"
74+
"doctest_encoding", "Encoding used for doctest files", default="utf-8"
7575
)
7676
group = parser.getgroup("collect")
7777
group.addoption(
7878
"--doctest-modules",
7979
action="store_true",
8080
default=False,
81-
help="run doctests in all .py modules",
81+
help="Run doctests in all .py modules",
8282
dest="doctestmodules",
8383
)
8484
group.addoption(
8585
"--doctest-report",
8686
type=str.lower,
8787
default="udiff",
88-
help="choose another output format for diffs on doctest failure",
88+
help="Choose another output format for diffs on doctest failure",
8989
choices=DOCTEST_REPORT_CHOICES,
9090
dest="doctestreport",
9191
)
@@ -94,21 +94,21 @@ def pytest_addoption(parser: Parser) -> None:
9494
action="append",
9595
default=[],
9696
metavar="pat",
97-
help="doctests file matching pattern, default: test*.txt",
97+
help="Doctests file matching pattern, default: test*.txt",
9898
dest="doctestglob",
9999
)
100100
group.addoption(
101101
"--doctest-ignore-import-errors",
102102
action="store_true",
103103
default=False,
104-
help="ignore doctest ImportErrors",
104+
help="Ignore doctest ImportErrors",
105105
dest="doctest_ignore_import_errors",
106106
)
107107
group.addoption(
108108
"--doctest-continue-on-failure",
109109
action="store_true",
110110
default=False,
111-
help="for a given doctest, continue to run after the first failure",
111+
help="For a given doctest, continue to run after the first failure",
112112
dest="doctest_continue_on_failure",
113113
)
114114

src/_pytest/faulthandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
def pytest_addoption(parser: Parser) -> None:
1919
help = (
2020
"Dump the traceback of all threads if a test takes "
21-
"more than TIMEOUT seconds to finish."
21+
"more than TIMEOUT seconds to finish"
2222
)
2323
parser.addini("faulthandler_timeout", help, default=0.0)
2424

src/_pytest/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ def pytest_addoption(parser: Parser) -> None:
13521352
"usefixtures",
13531353
type="args",
13541354
default=[],
1355-
help="list of default fixtures to be used with this project",
1355+
help="List of default fixtures to be used with this project",
13561356
)
13571357

13581358

src/_pytest/helpconfig.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@ def pytest_addoption(parser: Parser) -> None:
4949
action="count",
5050
default=0,
5151
dest="version",
52-
help="display pytest version and information about plugins. "
52+
help="Display pytest version and information about plugins. "
5353
"When given twice, also display information about plugins.",
5454
)
5555
group._addoption(
5656
"-h",
5757
"--help",
5858
action=HelpAction,
5959
dest="help",
60-
help="show help message and configuration info",
60+
help="Show help message and configuration info",
6161
)
6262
group._addoption(
6363
"-p",
6464
action="append",
6565
dest="plugins",
6666
default=[],
6767
metavar="name",
68-
help="early-load given plugin module name or entry point (multi-allowed).\n"
68+
help="Early-load given plugin module name or entry point (multi-allowed). "
6969
"To avoid loading of plugins, use the `no:` prefix, e.g. "
7070
"`no:doctest`.",
7171
)
@@ -74,7 +74,7 @@ def pytest_addoption(parser: Parser) -> None:
7474
"--trace-config",
7575
action="store_true",
7676
default=False,
77-
help="trace considerations of conftest.py files.",
77+
help="Trace considerations of conftest.py files",
7878
)
7979
group.addoption(
8080
"--debug",
@@ -83,16 +83,17 @@ def pytest_addoption(parser: Parser) -> None:
8383
const="pytestdebug.log",
8484
dest="debug",
8585
metavar="DEBUG_FILE_NAME",
86-
help="store internal tracing debug information in this log file.\n"
87-
"This file is opened with 'w' and truncated as a result, care advised.\n"
88-
"Defaults to 'pytestdebug.log'.",
86+
help="Store internal tracing debug information in this log file. "
87+
"This file is opened with 'w' and truncated as a result, care advised. "
88+
"Default: pytestdebug.log.",
8989
)
9090
group._addoption(
9191
"-o",
9292
"--override-ini",
9393
dest="override_ini",
9494
action="append",
95-
help='override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`.',
95+
help='Override ini option with "option=value" style, '
96+
"e.g. `-o xfail_strict=True -o cache_dir=cache`.",
9697
)
9798

9899

@@ -203,12 +204,12 @@ def showhelp(config: Config) -> None:
203204
tw.line(indent + line)
204205

205206
tw.line()
206-
tw.line("environment variables:")
207+
tw.line("Environment variables:")
207208
vars = [
208-
("PYTEST_ADDOPTS", "extra command line options"),
209-
("PYTEST_PLUGINS", "comma-separated plugins to load during startup"),
210-
("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "set to disable plugin auto-loading"),
211-
("PYTEST_DEBUG", "set to enable debug tracing of pytest's internals"),
209+
("PYTEST_ADDOPTS", "Extra command line options"),
210+
("PYTEST_PLUGINS", "Comma-separated plugins to load during startup"),
211+
("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "Set to disable plugin auto-loading"),
212+
("PYTEST_DEBUG", "Set to enable debug tracing of pytest's internals"),
212213
]
213214
for name, help in vars:
214215
tw.line(f" {name:<24} {help}")

src/_pytest/junitxml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ def pytest_addoption(parser: Parser) -> None:
386386
metavar="path",
387387
type=functools.partial(filename_arg, optname="--junitxml"),
388388
default=None,
389-
help="create junit-xml style report file at given path.",
389+
help="Create junit-xml style report file at given path",
390390
)
391391
group.addoption(
392392
"--junitprefix",
393393
"--junit-prefix",
394394
action="store",
395395
metavar="str",
396396
default=None,
397-
help="prepend prefix to classnames in junit-xml output",
397+
help="Prepend prefix to classnames in junit-xml output",
398398
)
399399
parser.addini(
400400
"junit_suite_name", "Test suite name for JUnit report", default="pytest"

src/_pytest/logging.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def pytest_addoption(parser: Parser) -> None:
218218

219219
def add_option_ini(option, dest, default=None, type=None, **kwargs):
220220
parser.addini(
221-
dest, default=default, type=type, help="default value for " + option
221+
dest, default=default, type=type, help="Default value for " + option
222222
)
223223
group.addoption(option, dest=dest, **kwargs)
224224

@@ -228,67 +228,67 @@ def add_option_ini(option, dest, default=None, type=None, **kwargs):
228228
default=None,
229229
metavar="LEVEL",
230230
help=(
231-
"level of messages to catch/display.\n"
232-
"Not set by default, so it depends on the root/parent log handler's"
231+
"Level of messages to catch/display."
232+
" Not set by default, so it depends on the root/parent log handler's"
233233
' effective level, where it is "WARNING" by default.'
234234
),
235235
)
236236
add_option_ini(
237237
"--log-format",
238238
dest="log_format",
239239
default=DEFAULT_LOG_FORMAT,
240-
help="log format as used by the logging module.",
240+
help="Log format used by the logging module",
241241
)
242242
add_option_ini(
243243
"--log-date-format",
244244
dest="log_date_format",
245245
default=DEFAULT_LOG_DATE_FORMAT,
246-
help="log date format as used by the logging module.",
246+
help="Log date format used by the logging module",
247247
)
248248
parser.addini(
249249
"log_cli",
250250
default=False,
251251
type="bool",
252-
help='enable log display during test run (also known as "live logging").',
252+
help='Enable log display during test run (also known as "live logging")',
253253
)
254254
add_option_ini(
255-
"--log-cli-level", dest="log_cli_level", default=None, help="cli logging level."
255+
"--log-cli-level", dest="log_cli_level", default=None, help="CLI logging level"
256256
)
257257
add_option_ini(
258258
"--log-cli-format",
259259
dest="log_cli_format",
260260
default=None,
261-
help="log format as used by the logging module.",
261+
help="Log format used by the logging module",
262262
)
263263
add_option_ini(
264264
"--log-cli-date-format",
265265
dest="log_cli_date_format",
266266
default=None,
267-
help="log date format as used by the logging module.",
267+
help="Log date format used by the logging module",
268268
)
269269
add_option_ini(
270270
"--log-file",
271271
dest="log_file",
272272
default=None,
273-
help="path to a file when logging will be written to.",
273+
help="Path to a file when logging will be written to",
274274
)
275275
add_option_ini(
276276
"--log-file-level",
277277
dest="log_file_level",
278278
default=None,
279-
help="log file logging level.",
279+
help="Log file logging level",
280280
)
281281
add_option_ini(
282282
"--log-file-format",
283283
dest="log_file_format",
284284
default=DEFAULT_LOG_FORMAT,
285-
help="log format as used by the logging module.",
285+
help="Log format used by the logging module",
286286
)
287287
add_option_ini(
288288
"--log-file-date-format",
289289
dest="log_file_date_format",
290290
default=DEFAULT_LOG_DATE_FORMAT,
291-
help="log date format as used by the logging module.",
291+
help="Log date format used by the logging module",
292292
)
293293
add_option_ini(
294294
"--log-auto-indent",

0 commit comments

Comments
 (0)