Skip to main content

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.

Release files for pytest-profiles 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pytest-profiles 0.2.0
File Interpreter ABI Platform
pytest_profiles-0.2.0-py3-none-any.whl Python 3 none any Details

Release files / pytest_profiles-0.2.0-py3-none-any.whl

Download URL pytest_profiles-0.2.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ebb66b55720cc8376bfe1c33ef764b7f73378395ec7288a9454b9d632bdd13b
BLAKE2b-256 checksum
How to use checksums
87dc79fc8a33fbd30c50556be76b8f3b83b24b315d45eb51162d1aa4bdded517
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page