Skip to content

Commit

Permalink
Document the --code-highlight default (#9883)
Browse files Browse the repository at this point in the history
Also normalized all help text using the patterns:

* `One sentence help text`
* `First sentence of help. Second sentence of help.`
  • Loading branch information
hugovk committed May 31, 2022
1 parent 9a8f5dd commit e54c6a1
Show file tree
Hide file tree
Showing 28 changed files with 279 additions and 272 deletions.
1 change: 1 addition & 0 deletions changelog/9883.improvement.rst
@@ -0,0 +1 @@
Normalize the help description of all command-line options.
282 changes: 141 additions & 141 deletions doc/en/reference/reference.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/_pytest/assertion/__init__.py
Expand Up @@ -39,7 +39,7 @@ def pytest_addoption(parser: Parser) -> None:
"enable_assertion_pass_hook",
type="bool",
default=False,
help="Enables the pytest_assertion_pass hook."
help="Enables the pytest_assertion_pass hook. "
"Make sure to delete any previously generated pyc cache files.",
)

Expand Down
14 changes: 7 additions & 7 deletions src/_pytest/cacheprovider.py
Expand Up @@ -440,15 +440,15 @@ def pytest_addoption(parser: Parser) -> None:
"--last-failed",
action="store_true",
dest="lf",
help="rerun only the tests that failed "
help="Rerun only the tests that failed "
"at the last run (or all if none failed)",
)
group.addoption(
"--ff",
"--failed-first",
action="store_true",
dest="failedfirst",
help="run all tests, but run the last failures first.\n"
help="Run all tests, but run the last failures first. "
"This may re-order tests and thus lead to "
"repeated fixture setup/teardown.",
)
Expand All @@ -457,7 +457,7 @@ def pytest_addoption(parser: Parser) -> None:
"--new-first",
action="store_true",
dest="newfirst",
help="run tests from new files first, then the rest of the tests "
help="Run tests from new files first, then the rest of the tests "
"sorted by file mtime",
)
group.addoption(
Expand All @@ -466,28 +466,28 @@ def pytest_addoption(parser: Parser) -> None:
nargs="?",
dest="cacheshow",
help=(
"show cache contents, don't perform collection or tests. "
"Show cache contents, don't perform collection or tests. "
"Optional argument: glob (default: '*')."
),
)
group.addoption(
"--cache-clear",
action="store_true",
dest="cacheclear",
help="remove all cache contents at start of test run.",
help="Remove all cache contents at start of test run",
)
cache_dir_default = ".pytest_cache"
if "TOX_ENV_DIR" in os.environ:
cache_dir_default = os.path.join(os.environ["TOX_ENV_DIR"], cache_dir_default)
parser.addini("cache_dir", default=cache_dir_default, help="cache directory path.")
parser.addini("cache_dir", default=cache_dir_default, help="Cache directory path")
group.addoption(
"--lfnf",
"--last-failed-no-failures",
action="store",
dest="last_failed_no_failures",
choices=("all", "none"),
default="all",
help="which tests to run with no previously (known) failures.",
help="Which tests to run with no previously (known) failures",
)


Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/capture.py
Expand Up @@ -42,14 +42,14 @@ def pytest_addoption(parser: Parser) -> None:
default="fd",
metavar="method",
choices=["fd", "sys", "no", "tee-sys"],
help="per-test capturing method: one of fd|sys|no|tee-sys.",
help="Per-test capturing method: one of fd|sys|no|tee-sys",
)
group._addoption(
"-s",
action="store_const",
const="no",
dest="capture",
help="shortcut for --capture=no.",
help="Shortcut for --capture=no",
)


Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/config/__init__.py
Expand Up @@ -1115,11 +1115,11 @@ def _initini(self, args: Sequence[str]) -> None:
self.inicfg = inicfg
self._parser.extra_info["rootdir"] = str(self.rootpath)
self._parser.extra_info["inifile"] = str(self.inipath)
self._parser.addini("addopts", "extra command line options", "args")
self._parser.addini("minversion", "minimally required pytest version")
self._parser.addini("addopts", "Extra command line options", "args")
self._parser.addini("minversion", "Minimally required pytest version")
self._parser.addini(
"required_plugins",
"plugins that must be present for pytest to run",
"Plugins that must be present for pytest to run",
type="args",
default=[],
)
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/config/argparsing.py
Expand Up @@ -48,7 +48,7 @@ def __init__(
_ispytest: bool = False,
) -> None:
check_ispytest(_ispytest)
self._anonymous = OptionGroup("custom options", parser=self, _ispytest=True)
self._anonymous = OptionGroup("Custom options", parser=self, _ispytest=True)
self._groups: List[OptionGroup] = []
self._processopt = processopt
self._usage = usage
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/debugging.py
Expand Up @@ -46,21 +46,21 @@ def pytest_addoption(parser: Parser) -> None:
"--pdb",
dest="usepdb",
action="store_true",
help="start the interactive Python debugger on errors or KeyboardInterrupt.",
help="Start the interactive Python debugger on errors or KeyboardInterrupt",
)
group._addoption(
"--pdbcls",
dest="usepdb_cls",
metavar="modulename:classname",
type=_validate_usepdb_cls,
help="specify a custom interactive Python debugger for use with --pdb."
help="Specify a custom interactive Python debugger for use with --pdb."
"For example: --pdbcls=IPython.terminal.debugger:TerminalPdb",
)
group._addoption(
"--trace",
dest="trace",
action="store_true",
help="Immediately break when running each test.",
help="Immediately break when running each test",
)


Expand Down
14 changes: 7 additions & 7 deletions src/_pytest/doctest.py
Expand Up @@ -66,26 +66,26 @@
def pytest_addoption(parser: Parser) -> None:
parser.addini(
"doctest_optionflags",
"option flags for doctests",
"Option flags for doctests",
type="args",
default=["ELLIPSIS"],
)
parser.addini(
"doctest_encoding", "encoding used for doctest files", default="utf-8"
"doctest_encoding", "Encoding used for doctest files", default="utf-8"
)
group = parser.getgroup("collect")
group.addoption(
"--doctest-modules",
action="store_true",
default=False,
help="run doctests in all .py modules",
help="Run doctests in all .py modules",
dest="doctestmodules",
)
group.addoption(
"--doctest-report",
type=str.lower,
default="udiff",
help="choose another output format for diffs on doctest failure",
help="Choose another output format for diffs on doctest failure",
choices=DOCTEST_REPORT_CHOICES,
dest="doctestreport",
)
Expand All @@ -94,21 +94,21 @@ def pytest_addoption(parser: Parser) -> None:
action="append",
default=[],
metavar="pat",
help="doctests file matching pattern, default: test*.txt",
help="Doctests file matching pattern, default: test*.txt",
dest="doctestglob",
)
group.addoption(
"--doctest-ignore-import-errors",
action="store_true",
default=False,
help="ignore doctest ImportErrors",
help="Ignore doctest ImportErrors",
dest="doctest_ignore_import_errors",
)
group.addoption(
"--doctest-continue-on-failure",
action="store_true",
default=False,
help="for a given doctest, continue to run after the first failure",
help="For a given doctest, continue to run after the first failure",
dest="doctest_continue_on_failure",
)

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/faulthandler.py
Expand Up @@ -18,7 +18,7 @@
def pytest_addoption(parser: Parser) -> None:
help = (
"Dump the traceback of all threads if a test takes "
"more than TIMEOUT seconds to finish."
"more than TIMEOUT seconds to finish"
)
parser.addini("faulthandler_timeout", help, default=0.0)

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/fixtures.py
Expand Up @@ -1352,7 +1352,7 @@ def pytest_addoption(parser: Parser) -> None:
"usefixtures",
type="args",
default=[],
help="list of default fixtures to be used with this project",
help="List of default fixtures to be used with this project",
)


Expand Down
27 changes: 14 additions & 13 deletions src/_pytest/helpconfig.py
Expand Up @@ -49,23 +49,23 @@ def pytest_addoption(parser: Parser) -> None:
action="count",
default=0,
dest="version",
help="display pytest version and information about plugins. "
help="Display pytest version and information about plugins. "
"When given twice, also display information about plugins.",
)
group._addoption(
"-h",
"--help",
action=HelpAction,
dest="help",
help="show help message and configuration info",
help="Show help message and configuration info",
)
group._addoption(
"-p",
action="append",
dest="plugins",
default=[],
metavar="name",
help="early-load given plugin module name or entry point (multi-allowed).\n"
help="Early-load given plugin module name or entry point (multi-allowed). "
"To avoid loading of plugins, use the `no:` prefix, e.g. "
"`no:doctest`.",
)
Expand All @@ -74,7 +74,7 @@ def pytest_addoption(parser: Parser) -> None:
"--trace-config",
action="store_true",
default=False,
help="trace considerations of conftest.py files.",
help="Trace considerations of conftest.py files",
)
group.addoption(
"--debug",
Expand All @@ -83,16 +83,17 @@ def pytest_addoption(parser: Parser) -> None:
const="pytestdebug.log",
dest="debug",
metavar="DEBUG_FILE_NAME",
help="store internal tracing debug information in this log file.\n"
"This file is opened with 'w' and truncated as a result, care advised.\n"
"Defaults to 'pytestdebug.log'.",
help="Store internal tracing debug information in this log file. "
"This file is opened with 'w' and truncated as a result, care advised. "
"Default: pytestdebug.log.",
)
group._addoption(
"-o",
"--override-ini",
dest="override_ini",
action="append",
help='override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`.',
help='Override ini option with "option=value" style, '
"e.g. `-o xfail_strict=True -o cache_dir=cache`.",
)


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

tw.line()
tw.line("environment variables:")
tw.line("Environment variables:")
vars = [
("PYTEST_ADDOPTS", "extra command line options"),
("PYTEST_PLUGINS", "comma-separated plugins to load during startup"),
("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "set to disable plugin auto-loading"),
("PYTEST_DEBUG", "set to enable debug tracing of pytest's internals"),
("PYTEST_ADDOPTS", "Extra command line options"),
("PYTEST_PLUGINS", "Comma-separated plugins to load during startup"),
("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "Set to disable plugin auto-loading"),
("PYTEST_DEBUG", "Set to enable debug tracing of pytest's internals"),
]
for name, help in vars:
tw.line(f" {name:<24} {help}")
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/junitxml.py
Expand Up @@ -386,15 +386,15 @@ def pytest_addoption(parser: Parser) -> None:
metavar="path",
type=functools.partial(filename_arg, optname="--junitxml"),
default=None,
help="create junit-xml style report file at given path.",
help="Create junit-xml style report file at given path",
)
group.addoption(
"--junitprefix",
"--junit-prefix",
action="store",
metavar="str",
default=None,
help="prepend prefix to classnames in junit-xml output",
help="Prepend prefix to classnames in junit-xml output",
)
parser.addini(
"junit_suite_name", "Test suite name for JUnit report", default="pytest"
Expand Down
26 changes: 13 additions & 13 deletions src/_pytest/logging.py
Expand Up @@ -218,7 +218,7 @@ def pytest_addoption(parser: Parser) -> None:

def add_option_ini(option, dest, default=None, type=None, **kwargs):
parser.addini(
dest, default=default, type=type, help="default value for " + option
dest, default=default, type=type, help="Default value for " + option
)
group.addoption(option, dest=dest, **kwargs)

Expand All @@ -228,67 +228,67 @@ def add_option_ini(option, dest, default=None, type=None, **kwargs):
default=None,
metavar="LEVEL",
help=(
"level of messages to catch/display.\n"
"Not set by default, so it depends on the root/parent log handler's"
"Level of messages to catch/display."
" Not set by default, so it depends on the root/parent log handler's"
' effective level, where it is "WARNING" by default.'
),
)
add_option_ini(
"--log-format",
dest="log_format",
default=DEFAULT_LOG_FORMAT,
help="log format as used by the logging module.",
help="Log format used by the logging module",
)
add_option_ini(
"--log-date-format",
dest="log_date_format",
default=DEFAULT_LOG_DATE_FORMAT,
help="log date format as used by the logging module.",
help="Log date format used by the logging module",
)
parser.addini(
"log_cli",
default=False,
type="bool",
help='enable log display during test run (also known as "live logging").',
help='Enable log display during test run (also known as "live logging")',
)
add_option_ini(
"--log-cli-level", dest="log_cli_level", default=None, help="cli logging level."
"--log-cli-level", dest="log_cli_level", default=None, help="CLI logging level"
)
add_option_ini(
"--log-cli-format",
dest="log_cli_format",
default=None,
help="log format as used by the logging module.",
help="Log format used by the logging module",
)
add_option_ini(
"--log-cli-date-format",
dest="log_cli_date_format",
default=None,
help="log date format as used by the logging module.",
help="Log date format used by the logging module",
)
add_option_ini(
"--log-file",
dest="log_file",
default=None,
help="path to a file when logging will be written to.",
help="Path to a file when logging will be written to",
)
add_option_ini(
"--log-file-level",
dest="log_file_level",
default=None,
help="log file logging level.",
help="Log file logging level",
)
add_option_ini(
"--log-file-format",
dest="log_file_format",
default=DEFAULT_LOG_FORMAT,
help="log format as used by the logging module.",
help="Log format used by the logging module",
)
add_option_ini(
"--log-file-date-format",
dest="log_file_date_format",
default=DEFAULT_LOG_DATE_FORMAT,
help="log date format as used by the logging module.",
help="Log date format used by the logging module",
)
add_option_ini(
"--log-auto-indent",
Expand Down

0 comments on commit e54c6a1

Please sign in to comment.