Skip to main content

pytest plugin for configuration profiles

Project description

pytest_profiles

Build Status Coverage PyPI Downloads License

pytest plugin to create configuration profiles.

Installation

$ pip install pytest_profiles

Usage

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pytest_profiles-0.2.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page