pytest plugin to create configuration profiles.
$ pip install pytest_profiles
Define your pytest configurations in a conftest.py
.
# conftest.py
from pytest_profiles import profile
from _pytest.config import Config
@profile(autouse=True)
def default(config: Config) -> None:
"""
sets pytest configuration options
which are always applied (autouse=True)
"""
config.option.verbose = 1
@profile
def custom(config: Config) -> None:
"""
sets pytest configuration options
only when `--profile custom` argument is applied.
"""
config.option.newfirst = True
config.option.failedfirst = True
activate profiles by passing command line arguments to pytest
# pytest runs with verbosity=1 by default
$ pytest
# pytest runs new and failed tests first
$ pytest --profile custom
It is also possible to define dependencies between profiles
# conftest.py
from pytest_profiles import profile
from _pytest.config import Config
@profile
def base(config: Config) -> None:
config.option.newfirst = True
config.option.failedfirst = True
@profile(uses=["base"])
def sub(config: Config) -> None:
"""the sub profile also includes the configuration of the base profile."""
config.option.verbose = 1
see conftest.py for more examples.