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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file pytest_profiles-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_profiles-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pytest_profiles-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ebb66b55720cc8376bfe1c33ef764b7f73378395ec7288a9454b9d632bdd13b
MD5 64dabf87089f93b5dee7c95ce678d725
BLAKE2b-256 87dc79fc8a33fbd30c50556be76b8f3b83b24b315d45eb51162d1aa4bdded517

See more details on using hashes here.

Supported by

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