pytest
The pytest Python test framework (https://docs.pytest.org/).
This version of Pants uses pytest
version 7.0.1 by default. Use a dedicated lockfile and the install_from_resolve
option to control this.
Backend: pants.backend.python
Config section: [pytest]
Basic options
args
--pytest-args="[<shell_str>, <shell_str>, ...]", ... -- [<shell_str> [<shell_str> [...]]]
PANTS_PYTEST_ARGS
[pytest]
args = [
<shell_str>,
<shell_str>,
...,
]
[]
Arguments to pass directly to Pytest, e.g. --pytest-args='-k test_foo --quiet'
.
skip
--[no-]pytest-skip
PANTS_PYTEST_SKIP
[pytest]
skip = <bool>
False
If true, don't use Pytest when running pants test
.
xdist_enabled
--[no-]pytest-xdist-enabled
PANTS_PYTEST_XDIST_ENABLED
[pytest]
xdist_enabled = <bool>
False
If true, Pants will use pytest-xdist
(https://pytest-xdist.readthedocs.io/en/latest/) to parallelize tests within each python_test
target.
NOTE: Enabling pytest-xdist
can cause high-level scoped fixtures (for example session
) to execute more than once. See the pytest-xdist
docs for more info: https://pypi.org/project/pytest-xdist/#making-session-scoped-fixtures-execute-only-once
Advanced options
config
--pytest-config=<file_option>
PANTS_PYTEST_CONFIG
[pytest]
config = <file_option>
None
Path to a config file understood by Pytest (https://docs.pytest.org/en/latest/reference/customize.html#configuration-file-formats). Setting this option will disable [pytest].config_discovery
. Use this option if the config is located in a non-standard location.
config_discovery
--[no-]pytest-config-discovery
PANTS_PYTEST_CONFIG_DISCOVERY
[pytest]
config_discovery = <bool>
True
If true, Pants will include all relevant Pytest config files (e.g. pytest.ini
) during runs. See https://docs.pytest.org/en/stable/customize.html#finding-the-rootdir for where config files should be located for Pytest to discover them.
Use [pytest].config
instead if your config is in a non-standard location.