Document the --code-highlight default (#9883)

Also normalized all help text using the patterns:

* `One sentence help text`
* `First sentence of help. Second sentence of help.`
This commit is contained in:
Hugo van Kemenade 2022-05-31 22:32:51 +03:00 committed by GitHub
parent 9a8f5dd73e
commit e54c6a1362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 279 additions and 272 deletions

View File

@ -0,0 +1 @@
Normalize the help description of all command-line options.

View File

@ -1752,11 +1752,11 @@ All the command-line flags can be obtained by running ``pytest --help``::
$ pytest --help $ pytest --help
usage: pytest [options] [file_or_dir] [file_or_dir] [...] usage: pytest [options] [file_or_dir] [file_or_dir] [...]
positional arguments: Positional arguments:
file_or_dir file_or_dir
general: General:
-k EXPRESSION only run tests which match the given substring -k EXPRESSION Only run tests which match the given substring
expression. An expression is a python evaluatable expression. An expression is a python evaluatable
expression where all names are substring-matched expression where all names are substring-matched
against test names and their parent classes. against test names and their parent classes.
@ -1771,214 +1771,214 @@ All the command-line flags can be obtained by running ``pytest --help``::
'extra_keyword_matches' set, as well as functions 'extra_keyword_matches' set, as well as functions
which have names assigned directly to them. The which have names assigned directly to them. The
matching is case-insensitive. matching is case-insensitive.
-m MARKEXPR only run tests matching given mark expression. -m MARKEXPR Only run tests matching given mark expression.
For example: -m 'mark1 and not mark2'. For example: -m 'mark1 and not mark2'.
--markers show markers (builtin, plugin and per-project ones). --markers Show markers (builtin, plugin and per-project ones)
-x, --exitfirst exit instantly on first error or failed test. -x, --exitfirst Exit instantly on first error or failed test
--fixtures, --funcargs --fixtures, --funcargs
show available fixtures, sorted by plugin appearance Show available fixtures, sorted by plugin appearance
(fixtures with leading '_' are only shown with '-v') (fixtures with leading '_' are only shown with '-v')
--fixtures-per-test show fixtures per test --fixtures-per-test Show fixtures per test
--pdb start the interactive Python debugger on errors or --pdb Start the interactive Python debugger on errors or
KeyboardInterrupt. KeyboardInterrupt
--pdbcls=modulename:classname --pdbcls=modulename:classname
specify a custom interactive Python debugger for use Specify a custom interactive Python debugger for use
with --pdb. For example: with --pdb. For example:
--pdbcls=IPython.terminal.debugger:TerminalPdb --pdbcls=IPython.terminal.debugger:TerminalPdb
--trace Immediately break when running each test. --trace Immediately break when running each test
--capture=method per-test capturing method: one of fd|sys|no|tee-sys. --capture=method Per-test capturing method: one of fd|sys|no|tee-sys.
-s shortcut for --capture=no. -s Shortcut for --capture=no.
--runxfail report the results of xfail tests as if they were --runxfail Report the results of xfail tests as if they were
not marked not marked
--lf, --last-failed rerun only the tests that failed at the last run (or --lf, --last-failed Rerun only the tests that failed at the last run (or
all if none failed) all if none failed)
--ff, --failed-first run all tests, but run the last failures first. --ff, --failed-first Run all tests, but run the last failures first
This may re-order tests and thus lead to repeated This may re-order tests and thus lead to repeated
fixture setup/teardown. fixture setup/teardown
--nf, --new-first run tests from new files first, then the rest of the --nf, --new-first Run tests from new files first, then the rest of the
tests sorted by file mtime tests sorted by file mtime
--cache-show=[CACHESHOW] --cache-show=[CACHESHOW]
show cache contents, don't perform collection or Show cache contents, don't perform collection or
tests. Optional argument: glob (default: '*'). tests. Optional argument: glob (default: '*').
--cache-clear remove all cache contents at start of test run. --cache-clear Remove all cache contents at start of test run
--lfnf={all,none}, --last-failed-no-failures={all,none} --lfnf={all,none}, --last-failed-no-failures={all,none}
which tests to run with no previously (known) Which tests to run with no previously (known)
failures. failures
--sw, --stepwise exit on test failure and continue from last failing --sw, --stepwise Exit on test failure and continue from last failing
test next time test next time
--sw-skip, --stepwise-skip --sw-skip, --stepwise-skip
ignore the first failing test but stop on the next Ignore the first failing test but stop on the next
failing test. failing test.
implicitly enables --stepwise. implicitly enables --stepwise.
reporting: Reporting:
--durations=N show N slowest setup/test durations (N=0 for all). --durations=N show N slowest setup/test durations (N=0 for all)
--durations-min=N Minimal duration in seconds for inclusion in slowest --durations-min=N Minimal duration in seconds for inclusion in slowest
list. Default 0.005 list. Default: 0.005.
-v, --verbose increase verbosity. -v, --verbose Increase verbosity
--no-header disable header --no-header Disable header
--no-summary disable summary --no-summary Disable summary
-q, --quiet decrease verbosity. -q, --quiet Decrease verbosity
--verbosity=VERBOSE set verbosity. Default is 0. --verbosity=VERBOSE Set verbosity. Default: 0.
-r chars show extra test summary info as specified by chars: -r chars Show extra test summary info as specified by chars:
(f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed, (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed,
(p)assed, (P)assed with output, (a)ll except passed (p)assed, (P)assed with output, (a)ll except passed
(p/P), or (A)ll. (w)arnings are enabled by default (p/P), or (A)ll. (w)arnings are enabled by default
(see --disable-warnings), 'N' can be used to reset (see --disable-warnings), 'N' can be used to reset
the list. (default: 'fE'). the list. (default: 'fE').
--disable-warnings, --disable-pytest-warnings --disable-warnings, --disable-pytest-warnings
disable warnings summary Disable warnings summary
-l, --showlocals show locals in tracebacks (disabled by default). -l, --showlocals Show locals in tracebacks (disabled by default)
--tb=style traceback print mode --tb=style Traceback print mode
(auto/long/short/line/native/no). (auto/long/short/line/native/no).
--show-capture={no,stdout,stderr,log,all} --show-capture={no,stdout,stderr,log,all}
Controls how captured stdout/stderr/log is shown on Controls how captured stdout/stderr/log is shown on
failed tests. Default is 'all'. failed tests. Default: all.
--full-trace don't cut any tracebacks (default is to cut). --full-trace Don't cut any tracebacks (default is to cut)
--color=color color terminal output (yes/no/auto). --color=color Color terminal output (yes/no/auto)
--code-highlight={yes,no} --code-highlight={yes,no}
Whether code should be highlighted (only if --color Whether code should be highlighted (only if --color
is also enabled) is also enabled). Default: yes.
--pastebin=mode send failed|all info to bpaste.net pastebin service. --pastebin=mode Send failed|all info to bpaste.net pastebin service
--junit-xml=path create junit-xml style report file at given path. --junit-xml=path Create junit-xml style report file at given path
--junit-prefix=str prepend prefix to classnames in junit-xml output --junit-prefix=str Prepend prefix to classnames in junit-xml output
pytest-warnings: pytest-warnings:
-W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS -W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS
set which warnings to report, see -W option of Set which warnings to report, see -W option of
python itself. Python itself
--maxfail=num exit after first num failures or errors. --maxfail=num Exit after first num failures or errors
--strict-config any warnings encountered while parsing the `pytest` --strict-config Any warnings encountered while parsing the `pytest`
section of the configuration file raise errors. section of the configuration file raise errors
--strict-markers markers not registered in the `markers` section of --strict-markers Markers not registered in the `markers` section of
the configuration file raise errors. the configuration file raise errors
--strict (deprecated) alias to --strict-markers. --strict (Deprecated) alias to --strict-markers
-c file load configuration from `file` instead of trying to -c file Load configuration from `file` instead of trying to
locate one of the implicit configuration files. locate one of the implicit configuration files
--continue-on-collection-errors --continue-on-collection-errors
Force test execution even if collection errors Force test execution even if collection errors
occur. occur
--rootdir=ROOTDIR Define root directory for tests. Can be relative --rootdir=ROOTDIR Define root directory for tests. Can be relative
path: 'root_dir', './root_dir', path: 'root_dir', './root_dir',
'root_dir/another_dir/'; absolute path: 'root_dir/another_dir/'; absolute path:
'/home/user/root_dir'; path with variables: '/home/user/root_dir'; path with variables:
'$HOME/root_dir'. '$HOME/root_dir'.
collection: Collection:
--collect-only, --co only collect tests, don't execute them. --collect-only, --co Only collect tests, don't execute them
--pyargs try to interpret all arguments as python packages. --pyargs Try to interpret all arguments as Python packages
--ignore=path ignore path during collection (multi-allowed). --ignore=path Ignore path during collection (multi-allowed)
--ignore-glob=path ignore path pattern during collection (multi- --ignore-glob=path Ignore path pattern during collection (multi-
allowed). allowed)
--deselect=nodeid_prefix --deselect=nodeid_prefix
deselect item (via node id prefix) during collection Deselect item (via node id prefix) during collection
(multi-allowed). (multi-allowed)
--confcutdir=dir only load conftest.py's relative to specified dir. --confcutdir=dir Only load conftest.py's relative to specified dir
--noconftest Don't load any conftest.py files. --noconftest Don't load any conftest.py files
--keep-duplicates Keep duplicate tests. --keep-duplicates Keep duplicate tests
--collect-in-virtualenv --collect-in-virtualenv
Don't ignore tests in a local virtualenv directory Don't ignore tests in a local virtualenv directory
--import-mode={prepend,append,importlib} --import-mode={prepend,append,importlib}
prepend/append to sys.path when importing test Prepend/append to sys.path when importing test
modules and conftest files, default is to prepend. modules and conftest files. Default: prepend.
--doctest-modules run doctests in all .py modules --doctest-modules Run doctests in all .py modules
--doctest-report={none,cdiff,ndiff,udiff,only_first_failure} --doctest-report={none,cdiff,ndiff,udiff,only_first_failure}
choose another output format for diffs on doctest Choose another output format for diffs on doctest
failure failure
--doctest-glob=pat doctests file matching pattern, default: test*.txt --doctest-glob=pat Doctests file matching pattern, default: test*.txt
--doctest-ignore-import-errors --doctest-ignore-import-errors
ignore doctest ImportErrors Ignore doctest ImportErrors
--doctest-continue-on-failure --doctest-continue-on-failure
for a given doctest, continue to run after the first For a given doctest, continue to run after the first
failure failure
test session debugging and configuration: Test session debugging and configuration:
--basetemp=dir base temporary directory for this test run.(warning: --basetemp=dir Base temporary directory for this test run. (Warning:
this directory is removed if it exists) this directory is removed if it exists.)
-V, --version display pytest version and information about -V, --version Display pytest version and information about
plugins. When given twice, also display information plugins. When given twice, also display information
about plugins. about plugins.
-h, --help show help message and configuration info -h, --help Show help message and configuration info
-p name early-load given plugin module name or entry point -p name Early-load given plugin module name or entry point
(multi-allowed). (multi-allowed)
To avoid loading of plugins, use the `no:` prefix, To avoid loading of plugins, use the `no:` prefix,
e.g. `no:doctest`. e.g. `no:doctest`
--trace-config trace considerations of conftest.py files. --trace-config Trace considerations of conftest.py files
--debug=[DEBUG_FILE_NAME] --debug=[DEBUG_FILE_NAME]
store internal tracing debug information in this log Store internal tracing debug information in this log
file. file.
This file is opened with 'w' and truncated as a This file is opened with 'w' and truncated as a
result, care advised. result, care advised.
Defaults to 'pytestdebug.log'. Default: pytestdebug.log.
-o OVERRIDE_INI, --override-ini=OVERRIDE_INI -o OVERRIDE_INI, --override-ini=OVERRIDE_INI
override ini option with "option=value" style, e.g. Override ini option with "option=value" style, e.g.
`-o xfail_strict=True -o cache_dir=cache`. `-o xfail_strict=True -o cache_dir=cache`
--assert=MODE Control assertion debugging tools. --assert=MODE Control assertion debugging tools.
'plain' performs no assertion debugging. 'plain' performs no assertion debugging.
'rewrite' (the default) rewrites assert statements 'rewrite' (the default) rewrites assert statements
in test modules on import to provide assert in test modules on import to provide assert
expression information. expression information.
--setup-only only setup fixtures, do not execute tests. --setup-only Only setup fixtures, do not execute tests
--setup-show show setup of fixtures while executing tests. --setup-show Show setup of fixtures while executing tests
--setup-plan show what fixtures and tests would be executed but --setup-plan Show what fixtures and tests would be executed but
don't execute anything. don't execute anything
logging: Logging:
--log-level=LEVEL level of messages to catch/display. --log-level=LEVEL Level of messages to catch/display.
Not set by default, so it depends on the root/parent Not set by default, so it depends on the root/parent
log handler's effective level, where it is "WARNING" log handler's effective level, where it is "WARNING"
by default. by default.
--log-format=LOG_FORMAT --log-format=LOG_FORMAT
log format as used by the logging module. Log format used by the logging module
--log-date-format=LOG_DATE_FORMAT --log-date-format=LOG_DATE_FORMAT
log date format as used by the logging module. Log date format used by the logging module
--log-cli-level=LOG_CLI_LEVEL --log-cli-level=LOG_CLI_LEVEL
cli logging level. CLI logging level
--log-cli-format=LOG_CLI_FORMAT --log-cli-format=LOG_CLI_FORMAT
log format as used by the logging module. Log format used by the logging module
--log-cli-date-format=LOG_CLI_DATE_FORMAT --log-cli-date-format=LOG_CLI_DATE_FORMAT
log date format as used by the logging module. Log date format used by the logging module
--log-file=LOG_FILE path to a file when logging will be written to. --log-file=LOG_FILE Path to a file when logging will be written to
--log-file-level=LOG_FILE_LEVEL --log-file-level=LOG_FILE_LEVEL
log file logging level. Log file logging level
--log-file-format=LOG_FILE_FORMAT --log-file-format=LOG_FILE_FORMAT
log format as used by the logging module. Log format used by the logging module
--log-file-date-format=LOG_FILE_DATE_FORMAT --log-file-date-format=LOG_FILE_DATE_FORMAT
log date format as used by the logging module. Log date format used by the logging module
--log-auto-indent=LOG_AUTO_INDENT --log-auto-indent=LOG_AUTO_INDENT
Auto-indent multiline messages passed to the logging Auto-indent multiline messages passed to the logging
module. Accepts true|on, false|off or an integer. module. Accepts true|on, false|off or an integer.
[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found: [pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:
markers (linelist): markers for test functions markers (linelist): Markers for test functions
empty_parameter_set_mark (string): empty_parameter_set_mark (string):
default marker for empty parametersets Default marker for empty parametersets
norecursedirs (args): directory patterns to avoid for recursion norecursedirs (args): Directory patterns to avoid for recursion
testpaths (args): directories to search for tests when no files or testpaths (args): Directories to search for tests when no files or
directories are given in the command line. directories are given in the command line
filterwarnings (linelist): filterwarnings (linelist):
Each line specifies a pattern for Each line specifies a pattern for
warnings.filterwarnings. Processed after warnings.filterwarnings. Processed after
-W/--pythonwarnings. -W/--pythonwarnings.
usefixtures (args): list of default fixtures to be used with this usefixtures (args): List of default fixtures to be used with this
project project
python_files (args): glob-style file patterns for Python test module python_files (args): Glob-style file patterns for Python test module
discovery discovery
python_classes (args): python_classes (args):
prefixes or glob names for Python test class Prefixes or glob names for Python test class
discovery discovery
python_functions (args): python_functions (args):
prefixes or glob names for Python test function and Prefixes or glob names for Python test function and
method discovery method discovery
disable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool): disable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool):
disable string escape non-ascii characters, might Disable string escape non-ASCII characters, might
cause unwanted side effects(use at your own risk) cause unwanted side effects(use at your own risk)
console_output_style (string): console_output_style (string):
console output: "classic", or with additional Console output: "classic", or with additional
progress information ("progress" (percentage) | progress information ("progress" (percentage) |
"count"). "count")
xfail_strict (bool): default for the strict parameter of xfail markers xfail_strict (bool): Default for the strict parameter of xfail markers
when not given explicitly (default: False) when not given explicitly (default: False)
enable_assertion_pass_hook (bool): enable_assertion_pass_hook (bool):
Enables the pytest_assertion_pass hook. Make sure to Enables the pytest_assertion_pass hook. Make sure to
@ -1996,45 +1996,45 @@ All the command-line flags can be obtained by running ``pytest --help``::
junit_family (string): junit_family (string):
Emit XML for schema: one of legacy|xunit1|xunit2 Emit XML for schema: one of legacy|xunit1|xunit2
doctest_optionflags (args): doctest_optionflags (args):
option flags for doctests Option flags for doctests
doctest_encoding (string): doctest_encoding (string):
encoding used for doctest files Encoding used for doctest files
cache_dir (string): cache directory path. cache_dir (string): Cache directory path
log_level (string): default value for --log-level log_level (string): Default value for --log-level
log_format (string): default value for --log-format log_format (string): Default value for --log-format
log_date_format (string): log_date_format (string):
default value for --log-date-format Default value for --log-date-format
log_cli (bool): enable log display during test run (also known as log_cli (bool): Enable log display during test run (also known as
"live logging"). "live logging")
log_cli_level (string): log_cli_level (string):
default value for --log-cli-level Default value for --log-cli-level
log_cli_format (string): log_cli_format (string):
default value for --log-cli-format Default value for --log-cli-format
log_cli_date_format (string): log_cli_date_format (string):
default value for --log-cli-date-format Default value for --log-cli-date-format
log_file (string): default value for --log-file log_file (string): Default value for --log-file
log_file_level (string): log_file_level (string):
default value for --log-file-level Default value for --log-file-level
log_file_format (string): log_file_format (string):
default value for --log-file-format Default value for --log-file-format
log_file_date_format (string): log_file_date_format (string):
default value for --log-file-date-format Default value for --log-file-date-format
log_auto_indent (string): log_auto_indent (string):
default value for --log-auto-indent Default value for --log-auto-indent
pythonpath (paths): Add paths to sys.path pythonpath (paths): Add paths to sys.path
faulthandler_timeout (string): faulthandler_timeout (string):
Dump the traceback of all threads if a test takes Dump the traceback of all threads if a test takes
more than TIMEOUT seconds to finish. more than TIMEOUT seconds to finish
addopts (args): extra command line options addopts (args): Extra command line options
minversion (string): minimally required pytest version minversion (string): Minimally required pytest version
required_plugins (args): required_plugins (args):
plugins that must be present for pytest to run Plugins that must be present for pytest to run
environment variables: Environment variables:
PYTEST_ADDOPTS extra command line options PYTEST_ADDOPTS Extra command line options
PYTEST_PLUGINS comma-separated plugins to load during startup PYTEST_PLUGINS Comma-separated plugins to load during startup
PYTEST_DISABLE_PLUGIN_AUTOLOAD set to disable plugin auto-loading PYTEST_DISABLE_PLUGIN_AUTOLOAD Set to disable plugin auto-loading
PYTEST_DEBUG set to enable debug tracing of pytest's internals PYTEST_DEBUG Set to enable debug tracing of pytest's internals
to see available markers type: pytest --markers to see available markers type: pytest --markers

View File

@ -440,7 +440,7 @@ def pytest_addoption(parser: Parser) -> None:
"--last-failed", "--last-failed",
action="store_true", action="store_true",
dest="lf", 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)", "at the last run (or all if none failed)",
) )
group.addoption( group.addoption(
@ -448,7 +448,7 @@ def pytest_addoption(parser: Parser) -> None:
"--failed-first", "--failed-first",
action="store_true", action="store_true",
dest="failedfirst", 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 " "This may re-order tests and thus lead to "
"repeated fixture setup/teardown.", "repeated fixture setup/teardown.",
) )
@ -457,7 +457,7 @@ def pytest_addoption(parser: Parser) -> None:
"--new-first", "--new-first",
action="store_true", action="store_true",
dest="newfirst", 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", "sorted by file mtime",
) )
group.addoption( group.addoption(
@ -466,7 +466,7 @@ def pytest_addoption(parser: Parser) -> None:
nargs="?", nargs="?",
dest="cacheshow", dest="cacheshow",
help=( help=(
"show cache contents, don't perform collection or tests. " "Show cache contents, don't perform collection or tests. "
"Optional argument: glob (default: '*')." "Optional argument: glob (default: '*')."
), ),
) )
@ -474,12 +474,12 @@ def pytest_addoption(parser: Parser) -> None:
"--cache-clear", "--cache-clear",
action="store_true", action="store_true",
dest="cacheclear", 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" cache_dir_default = ".pytest_cache"
if "TOX_ENV_DIR" in os.environ: if "TOX_ENV_DIR" in os.environ:
cache_dir_default = os.path.join(os.environ["TOX_ENV_DIR"], cache_dir_default) 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( group.addoption(
"--lfnf", "--lfnf",
"--last-failed-no-failures", "--last-failed-no-failures",
@ -487,7 +487,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="last_failed_no_failures", dest="last_failed_no_failures",
choices=("all", "none"), choices=("all", "none"),
default="all", default="all",
help="which tests to run with no previously (known) failures.", help="Which tests to run with no previously (known) failures",
) )

View File

@ -42,14 +42,14 @@ def pytest_addoption(parser: Parser) -> None:
default="fd", default="fd",
metavar="method", metavar="method",
choices=["fd", "sys", "no", "tee-sys"], 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( group._addoption(
"-s", "-s",
action="store_const", action="store_const",
const="no", const="no",
dest="capture", dest="capture",
help="shortcut for --capture=no.", help="Shortcut for --capture=no",
) )

View File

@ -1115,11 +1115,11 @@ class Config:
self.inicfg = inicfg self.inicfg = inicfg
self._parser.extra_info["rootdir"] = str(self.rootpath) self._parser.extra_info["rootdir"] = str(self.rootpath)
self._parser.extra_info["inifile"] = str(self.inipath) self._parser.extra_info["inifile"] = str(self.inipath)
self._parser.addini("addopts", "extra command line options", "args") self._parser.addini("addopts", "Extra command line options", "args")
self._parser.addini("minversion", "minimally required pytest version") self._parser.addini("minversion", "Minimally required pytest version")
self._parser.addini( self._parser.addini(
"required_plugins", "required_plugins",
"plugins that must be present for pytest to run", "Plugins that must be present for pytest to run",
type="args", type="args",
default=[], default=[],
) )

View File

@ -48,7 +48,7 @@ class Parser:
_ispytest: bool = False, _ispytest: bool = False,
) -> None: ) -> None:
check_ispytest(_ispytest) 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._groups: List[OptionGroup] = []
self._processopt = processopt self._processopt = processopt
self._usage = usage self._usage = usage

View File

@ -46,21 +46,21 @@ def pytest_addoption(parser: Parser) -> None:
"--pdb", "--pdb",
dest="usepdb", dest="usepdb",
action="store_true", 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( group._addoption(
"--pdbcls", "--pdbcls",
dest="usepdb_cls", dest="usepdb_cls",
metavar="modulename:classname", metavar="modulename:classname",
type=_validate_usepdb_cls, 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", "For example: --pdbcls=IPython.terminal.debugger:TerminalPdb",
) )
group._addoption( group._addoption(
"--trace", "--trace",
dest="trace", dest="trace",
action="store_true", action="store_true",
help="Immediately break when running each test.", help="Immediately break when running each test",
) )

View File

@ -66,26 +66,26 @@ CHECKER_CLASS: Optional[Type["doctest.OutputChecker"]] = None
def pytest_addoption(parser: Parser) -> None: def pytest_addoption(parser: Parser) -> None:
parser.addini( parser.addini(
"doctest_optionflags", "doctest_optionflags",
"option flags for doctests", "Option flags for doctests",
type="args", type="args",
default=["ELLIPSIS"], default=["ELLIPSIS"],
) )
parser.addini( 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 = parser.getgroup("collect")
group.addoption( group.addoption(
"--doctest-modules", "--doctest-modules",
action="store_true", action="store_true",
default=False, default=False,
help="run doctests in all .py modules", help="Run doctests in all .py modules",
dest="doctestmodules", dest="doctestmodules",
) )
group.addoption( group.addoption(
"--doctest-report", "--doctest-report",
type=str.lower, type=str.lower,
default="udiff", 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, choices=DOCTEST_REPORT_CHOICES,
dest="doctestreport", dest="doctestreport",
) )
@ -94,21 +94,21 @@ def pytest_addoption(parser: Parser) -> None:
action="append", action="append",
default=[], default=[],
metavar="pat", metavar="pat",
help="doctests file matching pattern, default: test*.txt", help="Doctests file matching pattern, default: test*.txt",
dest="doctestglob", dest="doctestglob",
) )
group.addoption( group.addoption(
"--doctest-ignore-import-errors", "--doctest-ignore-import-errors",
action="store_true", action="store_true",
default=False, default=False,
help="ignore doctest ImportErrors", help="Ignore doctest ImportErrors",
dest="doctest_ignore_import_errors", dest="doctest_ignore_import_errors",
) )
group.addoption( group.addoption(
"--doctest-continue-on-failure", "--doctest-continue-on-failure",
action="store_true", action="store_true",
default=False, 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", dest="doctest_continue_on_failure",
) )

View File

@ -18,7 +18,7 @@ fault_handler_originally_enabled_key = StashKey[bool]()
def pytest_addoption(parser: Parser) -> None: def pytest_addoption(parser: Parser) -> None:
help = ( help = (
"Dump the traceback of all threads if a test takes " "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) parser.addini("faulthandler_timeout", help, default=0.0)

View File

@ -1352,7 +1352,7 @@ def pytest_addoption(parser: Parser) -> None:
"usefixtures", "usefixtures",
type="args", type="args",
default=[], default=[],
help="list of default fixtures to be used with this project", help="List of default fixtures to be used with this project",
) )

View File

@ -49,7 +49,7 @@ def pytest_addoption(parser: Parser) -> None:
action="count", action="count",
default=0, default=0,
dest="version", 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.", "When given twice, also display information about plugins.",
) )
group._addoption( group._addoption(
@ -57,7 +57,7 @@ def pytest_addoption(parser: Parser) -> None:
"--help", "--help",
action=HelpAction, action=HelpAction,
dest="help", dest="help",
help="show help message and configuration info", help="Show help message and configuration info",
) )
group._addoption( group._addoption(
"-p", "-p",
@ -65,7 +65,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="plugins", dest="plugins",
default=[], default=[],
metavar="name", 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. " "To avoid loading of plugins, use the `no:` prefix, e.g. "
"`no:doctest`.", "`no:doctest`.",
) )
@ -74,7 +74,7 @@ def pytest_addoption(parser: Parser) -> None:
"--trace-config", "--trace-config",
action="store_true", action="store_true",
default=False, default=False,
help="trace considerations of conftest.py files.", help="Trace considerations of conftest.py files",
) )
group.addoption( group.addoption(
"--debug", "--debug",
@ -83,16 +83,17 @@ def pytest_addoption(parser: Parser) -> None:
const="pytestdebug.log", const="pytestdebug.log",
dest="debug", dest="debug",
metavar="DEBUG_FILE_NAME", metavar="DEBUG_FILE_NAME",
help="store internal tracing debug information in this log file.\n" help="Store internal tracing debug information in this log file. "
"This file is opened with 'w' and truncated as a result, care advised.\n" "This file is opened with 'w' and truncated as a result, care advised. "
"Defaults to 'pytestdebug.log'.", "Default: pytestdebug.log.",
) )
group._addoption( group._addoption(
"-o", "-o",
"--override-ini", "--override-ini",
dest="override_ini", dest="override_ini",
action="append", 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`.",
) )
@ -203,12 +204,12 @@ def showhelp(config: Config) -> None:
tw.line(indent + line) tw.line(indent + line)
tw.line() tw.line()
tw.line("environment variables:") tw.line("Environment variables:")
vars = [ vars = [
("PYTEST_ADDOPTS", "extra command line options"), ("PYTEST_ADDOPTS", "Extra command line options"),
("PYTEST_PLUGINS", "comma-separated plugins to load during startup"), ("PYTEST_PLUGINS", "Comma-separated plugins to load during startup"),
("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "set to disable plugin auto-loading"), ("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "Set to disable plugin auto-loading"),
("PYTEST_DEBUG", "set to enable debug tracing of pytest's internals"), ("PYTEST_DEBUG", "Set to enable debug tracing of pytest's internals"),
] ]
for name, help in vars: for name, help in vars:
tw.line(f" {name:<24} {help}") tw.line(f" {name:<24} {help}")

View File

@ -386,7 +386,7 @@ def pytest_addoption(parser: Parser) -> None:
metavar="path", metavar="path",
type=functools.partial(filename_arg, optname="--junitxml"), type=functools.partial(filename_arg, optname="--junitxml"),
default=None, default=None,
help="create junit-xml style report file at given path.", help="Create junit-xml style report file at given path",
) )
group.addoption( group.addoption(
"--junitprefix", "--junitprefix",
@ -394,7 +394,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store", action="store",
metavar="str", metavar="str",
default=None, default=None,
help="prepend prefix to classnames in junit-xml output", help="Prepend prefix to classnames in junit-xml output",
) )
parser.addini( parser.addini(
"junit_suite_name", "Test suite name for JUnit report", default="pytest" "junit_suite_name", "Test suite name for JUnit report", default="pytest"

View File

@ -218,7 +218,7 @@ def pytest_addoption(parser: Parser) -> None:
def add_option_ini(option, dest, default=None, type=None, **kwargs): def add_option_ini(option, dest, default=None, type=None, **kwargs):
parser.addini( 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) group.addoption(option, dest=dest, **kwargs)
@ -228,7 +228,7 @@ def pytest_addoption(parser: Parser) -> None:
default=None, default=None,
metavar="LEVEL", metavar="LEVEL",
help=( help=(
"level of messages to catch/display.\n" "Level of messages to catch/display."
" Not set by default, so it depends on the root/parent log handler's" " Not set by default, so it depends on the root/parent log handler's"
' effective level, where it is "WARNING" by default.' ' effective level, where it is "WARNING" by default.'
), ),
@ -237,58 +237,58 @@ def pytest_addoption(parser: Parser) -> None:
"--log-format", "--log-format",
dest="log_format", dest="log_format",
default=DEFAULT_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( add_option_ini(
"--log-date-format", "--log-date-format",
dest="log_date_format", dest="log_date_format",
default=DEFAULT_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( parser.addini(
"log_cli", "log_cli",
default=False, default=False,
type="bool", 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( 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( add_option_ini(
"--log-cli-format", "--log-cli-format",
dest="log_cli_format", dest="log_cli_format",
default=None, default=None,
help="log format as used by the logging module.", help="Log format used by the logging module",
) )
add_option_ini( add_option_ini(
"--log-cli-date-format", "--log-cli-date-format",
dest="log_cli_date_format", dest="log_cli_date_format",
default=None, default=None,
help="log date format as used by the logging module.", help="Log date format used by the logging module",
) )
add_option_ini( add_option_ini(
"--log-file", "--log-file",
dest="log_file", dest="log_file",
default=None, 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( add_option_ini(
"--log-file-level", "--log-file-level",
dest="log_file_level", dest="log_file_level",
default=None, default=None,
help="log file logging level.", help="Log file logging level",
) )
add_option_ini( add_option_ini(
"--log-file-format", "--log-file-format",
dest="log_file_format", dest="log_file_format",
default=DEFAULT_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( add_option_ini(
"--log-file-date-format", "--log-file-date-format",
dest="log_file_date_format", dest="log_file_date_format",
default=DEFAULT_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",
) )
add_option_ini( add_option_ini(
"--log-auto-indent", "--log-auto-indent",

View File

@ -51,7 +51,7 @@ if TYPE_CHECKING:
def pytest_addoption(parser: Parser) -> None: def pytest_addoption(parser: Parser) -> None:
parser.addini( parser.addini(
"norecursedirs", "norecursedirs",
"directory patterns to avoid for recursion", "Directory patterns to avoid for recursion",
type="args", type="args",
default=[ default=[
"*.egg", "*.egg",
@ -67,26 +67,26 @@ def pytest_addoption(parser: Parser) -> None:
) )
parser.addini( parser.addini(
"testpaths", "testpaths",
"directories to search for tests when no files or directories are given in the " "Directories to search for tests when no files or directories are given on the "
"command line.", "command line",
type="args", type="args",
default=[], default=[],
) )
group = parser.getgroup("general", "running and selection options") group = parser.getgroup("general", "Running and selection options")
group._addoption( group._addoption(
"-x", "-x",
"--exitfirst", "--exitfirst",
action="store_const", action="store_const",
dest="maxfail", dest="maxfail",
const=1, const=1,
help="exit instantly on first error or failed test.", help="Exit instantly on first error or failed test",
) )
group = parser.getgroup("pytest-warnings") group = parser.getgroup("pytest-warnings")
group.addoption( group.addoption(
"-W", "-W",
"--pythonwarnings", "--pythonwarnings",
action="append", action="append",
help="set which warnings to report, see -W option of python itself.", help="Set which warnings to report, see -W option of Python itself",
) )
parser.addini( parser.addini(
"filterwarnings", "filterwarnings",
@ -102,37 +102,39 @@ def pytest_addoption(parser: Parser) -> None:
type=int, type=int,
dest="maxfail", dest="maxfail",
default=0, default=0,
help="exit after first num failures or errors.", help="Exit after first num failures or errors",
) )
group._addoption( group._addoption(
"--strict-config", "--strict-config",
action="store_true", action="store_true",
help="any warnings encountered while parsing the `pytest` section of the configuration file raise errors.", help="Any warnings encountered while parsing the `pytest` section of the "
"configuration file raise errors",
) )
group._addoption( group._addoption(
"--strict-markers", "--strict-markers",
action="store_true", action="store_true",
help="markers not registered in the `markers` section of the configuration file raise errors.", help="Markers not registered in the `markers` section of the configuration "
"file raise errors",
) )
group._addoption( group._addoption(
"--strict", "--strict",
action="store_true", action="store_true",
help="(deprecated) alias to --strict-markers.", help="(Deprecated) alias to --strict-markers",
) )
group._addoption( group._addoption(
"-c", "-c",
metavar="file", metavar="file",
type=str, type=str,
dest="inifilename", dest="inifilename",
help="load configuration from `file` instead of trying to locate one of the implicit " help="Load configuration from `file` instead of trying to locate one of the "
"configuration files.", "implicit configuration files",
) )
group._addoption( group._addoption(
"--continue-on-collection-errors", "--continue-on-collection-errors",
action="store_true", action="store_true",
default=False, default=False,
dest="continue_on_collection_errors", dest="continue_on_collection_errors",
help="Force test execution even if collection errors occur.", help="Force test execution even if collection errors occur",
) )
group._addoption( group._addoption(
"--rootdir", "--rootdir",
@ -149,30 +151,30 @@ def pytest_addoption(parser: Parser) -> None:
"--collect-only", "--collect-only",
"--co", "--co",
action="store_true", action="store_true",
help="only collect tests, don't execute them.", help="Only collect tests, don't execute them",
) )
group.addoption( group.addoption(
"--pyargs", "--pyargs",
action="store_true", action="store_true",
help="try to interpret all arguments as python packages.", help="Try to interpret all arguments as Python packages",
) )
group.addoption( group.addoption(
"--ignore", "--ignore",
action="append", action="append",
metavar="path", metavar="path",
help="ignore path during collection (multi-allowed).", help="Ignore path during collection (multi-allowed)",
) )
group.addoption( group.addoption(
"--ignore-glob", "--ignore-glob",
action="append", action="append",
metavar="path", metavar="path",
help="ignore path pattern during collection (multi-allowed).", help="Ignore path pattern during collection (multi-allowed)",
) )
group.addoption( group.addoption(
"--deselect", "--deselect",
action="append", action="append",
metavar="nodeid_prefix", metavar="nodeid_prefix",
help="deselect item (via node id prefix) during collection (multi-allowed).", help="Deselect item (via node id prefix) during collection (multi-allowed)",
) )
group.addoption( group.addoption(
"--confcutdir", "--confcutdir",
@ -180,14 +182,14 @@ def pytest_addoption(parser: Parser) -> None:
default=None, default=None,
metavar="dir", metavar="dir",
type=functools.partial(directory_arg, optname="--confcutdir"), type=functools.partial(directory_arg, optname="--confcutdir"),
help="only load conftest.py's relative to specified dir.", help="Only load conftest.py's relative to specified dir",
) )
group.addoption( group.addoption(
"--noconftest", "--noconftest",
action="store_true", action="store_true",
dest="noconftest", dest="noconftest",
default=False, default=False,
help="Don't load any conftest.py files.", help="Don't load any conftest.py files",
) )
group.addoption( group.addoption(
"--keepduplicates", "--keepduplicates",
@ -195,7 +197,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
dest="keepduplicates", dest="keepduplicates",
default=False, default=False,
help="Keep duplicate tests.", help="Keep duplicate tests",
) )
group.addoption( group.addoption(
"--collect-in-virtualenv", "--collect-in-virtualenv",
@ -209,8 +211,8 @@ def pytest_addoption(parser: Parser) -> None:
default="prepend", default="prepend",
choices=["prepend", "append", "importlib"], choices=["prepend", "append", "importlib"],
dest="importmode", dest="importmode",
help="prepend/append to sys.path when importing test modules and conftest files, " help="Prepend/append to sys.path when importing test modules and conftest "
"default is to prepend.", "files. Default: prepend.",
) )
group = parser.getgroup("debugconfig", "test session debugging and configuration") group = parser.getgroup("debugconfig", "test session debugging and configuration")
@ -221,8 +223,8 @@ def pytest_addoption(parser: Parser) -> None:
type=validate_basetemp, type=validate_basetemp,
metavar="dir", metavar="dir",
help=( help=(
"base temporary directory for this test run." "Base temporary directory for this test run. "
"(warning: this directory is removed if it exists)" "(Warning: this directory is removed if it exists.)"
), ),
) )

View File

@ -76,8 +76,8 @@ def pytest_addoption(parser: Parser) -> None:
dest="keyword", dest="keyword",
default="", default="",
metavar="EXPRESSION", metavar="EXPRESSION",
help="only run tests which match the given substring expression. " help="Only run tests which match the given substring expression. "
"An expression is a python evaluatable expression " "An expression is a Python evaluatable expression "
"where all names are substring-matched against test names " "where all names are substring-matched against test names "
"and their parent classes. Example: -k 'test_method or test_" "and their parent classes. Example: -k 'test_method or test_"
"other' matches all test functions and classes whose name " "other' matches all test functions and classes whose name "
@ -96,7 +96,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="markexpr", dest="markexpr",
default="", default="",
metavar="MARKEXPR", metavar="MARKEXPR",
help="only run tests matching given mark expression.\n" help="Only run tests matching given mark expression. "
"For example: -m 'mark1 and not mark2'.", "For example: -m 'mark1 and not mark2'.",
) )
@ -106,8 +106,8 @@ def pytest_addoption(parser: Parser) -> None:
help="show markers (builtin, plugin and per-project ones).", help="show markers (builtin, plugin and per-project ones).",
) )
parser.addini("markers", "markers for test functions", "linelist") parser.addini("markers", "Markers for test functions", "linelist")
parser.addini(EMPTY_PARAMETERSET_OPTION, "default marker for empty parametersets") parser.addini(EMPTY_PARAMETERSET_OPTION, "Default marker for empty parametersets")
@hookimpl(tryfirst=True) @hookimpl(tryfirst=True)

View File

@ -24,7 +24,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="pastebin", dest="pastebin",
default=None, default=None,
choices=["failed", "all"], choices=["failed", "all"],
help="send failed|all info to bpaste.net pastebin service.", help="Send failed|all info to bpaste.net pastebin service",
) )

View File

@ -89,7 +89,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
dest="lsof", dest="lsof",
default=False, default=False,
help="run FD checks if lsof is available", help="Run FD checks if lsof is available",
) )
parser.addoption( parser.addoption(
@ -98,13 +98,13 @@ def pytest_addoption(parser: Parser) -> None:
dest="runpytest", dest="runpytest",
choices=("inprocess", "subprocess"), choices=("inprocess", "subprocess"),
help=( help=(
"run pytest sub runs in tests using an 'inprocess' " "Run pytest sub runs in tests using an 'inprocess' "
"or 'subprocess' (python -m main) method" "or 'subprocess' (python -m main) method"
), ),
) )
parser.addini( parser.addini(
"pytester_example_dir", help="directory to take the pytester example files from" "pytester_example_dir", help="Directory to take the pytester example files from"
) )

View File

@ -97,7 +97,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
dest="showfixtures", dest="showfixtures",
default=False, default=False,
help="show available fixtures, sorted by plugin appearance " help="Show available fixtures, sorted by plugin appearance "
"(fixtures with leading '_' are only shown with '-v')", "(fixtures with leading '_' are only shown with '-v')",
) )
group.addoption( group.addoption(
@ -105,32 +105,32 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
dest="show_fixtures_per_test", dest="show_fixtures_per_test",
default=False, default=False,
help="show fixtures per test", help="Show fixtures per test",
) )
parser.addini( parser.addini(
"python_files", "python_files",
type="args", type="args",
# NOTE: default is also used in AssertionRewritingHook. # NOTE: default is also used in AssertionRewritingHook.
default=["test_*.py", "*_test.py"], default=["test_*.py", "*_test.py"],
help="glob-style file patterns for Python test module discovery", help="Glob-style file patterns for Python test module discovery",
) )
parser.addini( parser.addini(
"python_classes", "python_classes",
type="args", type="args",
default=["Test"], default=["Test"],
help="prefixes or glob names for Python test class discovery", help="Prefixes or glob names for Python test class discovery",
) )
parser.addini( parser.addini(
"python_functions", "python_functions",
type="args", type="args",
default=["test"], default=["test"],
help="prefixes or glob names for Python test function and method discovery", help="Prefixes or glob names for Python test function and method discovery",
) )
parser.addini( parser.addini(
"disable_test_id_escaping_and_forfeit_all_rights_to_community_support", "disable_test_id_escaping_and_forfeit_all_rights_to_community_support",
type="bool", type="bool",
default=False, default=False,
help="disable string escape non-ascii characters, might cause unwanted " help="Disable string escape non-ASCII characters, might cause unwanted "
"side effects(use at your own risk)", "side effects(use at your own risk)",
) )

View File

@ -46,14 +46,14 @@ if TYPE_CHECKING:
def pytest_addoption(parser: Parser) -> None: def pytest_addoption(parser: Parser) -> None:
group = parser.getgroup("terminal reporting", "reporting", after="general") group = parser.getgroup("terminal reporting", "Reporting", after="general")
group.addoption( group.addoption(
"--durations", "--durations",
action="store", action="store",
type=int, type=int,
default=None, default=None,
metavar="N", metavar="N",
help="show N slowest setup/test durations (N=0 for all).", help="Show N slowest setup/test durations (N=0 for all)",
) )
group.addoption( group.addoption(
"--durations-min", "--durations-min",
@ -61,7 +61,8 @@ def pytest_addoption(parser: Parser) -> None:
type=float, type=float,
default=0.005, default=0.005,
metavar="N", metavar="N",
help="Minimal duration in seconds for inclusion in slowest list. Default 0.005", help="Minimal duration in seconds for inclusion in slowest list. "
"Default: 0.005.",
) )

View File

@ -18,13 +18,13 @@ def pytest_addoption(parser: Parser) -> None:
"--setuponly", "--setuponly",
"--setup-only", "--setup-only",
action="store_true", action="store_true",
help="only setup fixtures, do not execute tests.", help="Only setup fixtures, do not execute tests",
) )
group.addoption( group.addoption(
"--setupshow", "--setupshow",
"--setup-show", "--setup-show",
action="store_true", action="store_true",
help="show setup of fixtures while executing tests.", help="Show setup of fixtures while executing tests",
) )

View File

@ -15,8 +15,8 @@ def pytest_addoption(parser: Parser) -> None:
"--setupplan", "--setupplan",
"--setup-plan", "--setup-plan",
action="store_true", action="store_true",
help="show what fixtures and tests would be executed but " help="Show what fixtures and tests would be executed but "
"don't execute anything.", "don't execute anything",
) )

View File

@ -31,12 +31,12 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
dest="runxfail", dest="runxfail",
default=False, default=False,
help="report the results of xfail tests as if they were not marked", help="Report the results of xfail tests as if they were not marked",
) )
parser.addini( parser.addini(
"xfail_strict", "xfail_strict",
"default for the strict parameter of xfail " "Default for the strict parameter of xfail "
"markers when not given explicitly (default: False)", "markers when not given explicitly (default: False)",
default=False, default=False,
type="bool", type="bool",

View File

@ -23,7 +23,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
default=False, default=False,
dest="stepwise", dest="stepwise",
help="exit on test failure and continue from last failing test next time", help="Exit on test failure and continue from last failing test next time",
) )
group.addoption( group.addoption(
"--sw-skip", "--sw-skip",
@ -31,8 +31,8 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
default=False, default=False,
dest="stepwise_skip", dest="stepwise_skip",
help="ignore the first failing test but stop on the next failing test.\n" help="Ignore the first failing test but stop on the next failing test. "
"implicitly enables --stepwise.", "Implicitly enables --stepwise.",
) )

View File

@ -112,28 +112,28 @@ class MoreQuietAction(argparse.Action):
def pytest_addoption(parser: Parser) -> None: def pytest_addoption(parser: Parser) -> None:
group = parser.getgroup("terminal reporting", "reporting", after="general") group = parser.getgroup("terminal reporting", "Reporting", after="general")
group._addoption( group._addoption(
"-v", "-v",
"--verbose", "--verbose",
action="count", action="count",
default=0, default=0,
dest="verbose", dest="verbose",
help="increase verbosity.", help="Increase verbosity",
) )
group._addoption( group._addoption(
"--no-header", "--no-header",
action="store_true", action="store_true",
default=False, default=False,
dest="no_header", dest="no_header",
help="disable header", help="Disable header",
) )
group._addoption( group._addoption(
"--no-summary", "--no-summary",
action="store_true", action="store_true",
default=False, default=False,
dest="no_summary", dest="no_summary",
help="disable summary", help="Disable summary",
) )
group._addoption( group._addoption(
"-q", "-q",
@ -141,14 +141,14 @@ def pytest_addoption(parser: Parser) -> None:
action=MoreQuietAction, action=MoreQuietAction,
default=0, default=0,
dest="verbose", dest="verbose",
help="decrease verbosity.", help="Decrease verbosity",
) )
group._addoption( group._addoption(
"--verbosity", "--verbosity",
dest="verbose", dest="verbose",
type=int, type=int,
default=0, default=0,
help="set verbosity. Default is 0.", help="Set verbosity. Default: 0.",
) )
group._addoption( group._addoption(
"-r", "-r",
@ -156,7 +156,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="reportchars", dest="reportchars",
default=_REPORTCHARS_DEFAULT, default=_REPORTCHARS_DEFAULT,
metavar="chars", metavar="chars",
help="show extra test summary info as specified by chars: (f)ailed, " help="Show extra test summary info as specified by chars: (f)ailed, "
"(E)rror, (s)kipped, (x)failed, (X)passed, " "(E)rror, (s)kipped, (x)failed, (X)passed, "
"(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. " "(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. "
"(w)arnings are enabled by default (see --disable-warnings), " "(w)arnings are enabled by default (see --disable-warnings), "
@ -168,7 +168,7 @@ def pytest_addoption(parser: Parser) -> None:
default=False, default=False,
dest="disable_warnings", dest="disable_warnings",
action="store_true", action="store_true",
help="disable warnings summary", help="Disable warnings summary",
) )
group._addoption( group._addoption(
"-l", "-l",
@ -176,7 +176,7 @@ def pytest_addoption(parser: Parser) -> None:
action="store_true", action="store_true",
dest="showlocals", dest="showlocals",
default=False, default=False,
help="show locals in tracebacks (disabled by default).", help="Show locals in tracebacks (disabled by default)",
) )
group._addoption( group._addoption(
"--tb", "--tb",
@ -185,7 +185,7 @@ def pytest_addoption(parser: Parser) -> None:
dest="tbstyle", dest="tbstyle",
default="auto", default="auto",
choices=["auto", "long", "short", "no", "line", "native"], choices=["auto", "long", "short", "no", "line", "native"],
help="traceback print mode (auto/long/short/line/native/no).", help="Traceback print mode (auto/long/short/line/native/no)",
) )
group._addoption( group._addoption(
"--show-capture", "--show-capture",
@ -194,14 +194,14 @@ def pytest_addoption(parser: Parser) -> None:
choices=["no", "stdout", "stderr", "log", "all"], choices=["no", "stdout", "stderr", "log", "all"],
default="all", default="all",
help="Controls how captured stdout/stderr/log is shown on failed tests. " help="Controls how captured stdout/stderr/log is shown on failed tests. "
"Default is 'all'.", "Default: all.",
) )
group._addoption( group._addoption(
"--fulltrace", "--fulltrace",
"--full-trace", "--full-trace",
action="store_true", action="store_true",
default=False, default=False,
help="don't cut any tracebacks (default is to cut).", help="Don't cut any tracebacks (default is to cut)",
) )
group._addoption( group._addoption(
"--color", "--color",
@ -210,18 +210,20 @@ def pytest_addoption(parser: Parser) -> None:
dest="color", dest="color",
default="auto", default="auto",
choices=["yes", "no", "auto"], choices=["yes", "no", "auto"],
help="color terminal output (yes/no/auto).", help="Color terminal output (yes/no/auto)",
) )
group._addoption( group._addoption(
"--code-highlight", "--code-highlight",
default="yes", default="yes",
choices=["yes", "no"], choices=["yes", "no"],
help="Whether code should be highlighted (only if --color is also enabled)", help="Whether code should be highlighted (only if --color is also enabled). "
"Default: yes.",
) )
parser.addini( parser.addini(
"console_output_style", "console_output_style",
help='console output: "classic", or with additional progress information ("progress" (percentage) | "count").', help='Console output: "classic", or with additional progress information '
'("progress" (percentage) | "count")',
default="progress", default="progress",
) )

View File

@ -2117,8 +2117,8 @@ class TestDebugOptions:
result = pytester.runpytest("-h") result = pytester.runpytest("-h")
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
[ [
"*store internal tracing debug information in this log*", "*Store internal tracing debug information in this log*",
"*This file is opened with 'w' and truncated as a result*", "*file. This file is opened with 'w' and truncated as a*",
"*Defaults to 'pytestdebug.log'.", "*Default: pytestdebug.log.",
] ]
) )

View File

@ -30,11 +30,11 @@ def test_help(pytester: Pytester) -> None:
assert result.ret == 0 assert result.ret == 0
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
""" """
-m MARKEXPR only run tests matching given mark expression. -m MARKEXPR Only run tests matching given mark expression. For
For example: -m 'mark1 and not mark2'. example: -m 'mark1 and not mark2'.
reporting: Reporting:
--durations=N * --durations=N *
-V, --version display pytest version and information about plugins. -V, --version Display pytest version and information about plugins.
When given twice, also display information about When given twice, also display information about
plugins. plugins.
*setup.cfg* *setup.cfg*
@ -71,9 +71,9 @@ def test_empty_help_param(pytester: Pytester) -> None:
assert result.ret == 0 assert result.ret == 0
lines = [ lines = [
" required_plugins (args):", " required_plugins (args):",
" plugins that must be present for pytest to run*", " Plugins that must be present for pytest to run*",
" test_ini (bool):*", " test_ini (bool):*",
"environment variables:", "Environment variables:",
] ]
result.stdout.fnmatch_lines(lines, consecutive=True) result.stdout.fnmatch_lines(lines, consecutive=True)

View File

@ -277,4 +277,4 @@ def test_stepwise_skip_is_independent(pytester: Pytester) -> None:
def test_sw_skip_help(pytester: Pytester) -> None: def test_sw_skip_help(pytester: Pytester) -> None:
result = pytester.runpytest("-h") result = pytester.runpytest("-h")
result.stdout.fnmatch_lines("*implicitly enables --stepwise.") result.stdout.fnmatch_lines("*Implicitly enables --stepwise.")