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 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page