[tox]
envlist = tests
requires =
    tox>=3.25.0,<4
    tox-envfile
    tox-faster
    tox-run-command
    tox-recreate
isolated_build = true

[testenv]
skip_install =
    format,checkformatting,coverage,template: true
setenv =
    PYTHONUNBUFFERED = 1
    OBJC_DISABLE_INITIALIZE_FORK_SAFETY = YES
    dev: DEV = {env:DEV:true}
    dev: SENTRY_ENVIRONMENT = {env:SENTRY_ENVIRONMENT:dev}
    dev: NEW_RELIC_APP_NAME = {env:NEW_RELIC_APP_NAME:h-api}
    dev: NEW_RELIC_ENVIRONMENT = {env:NEW_RELIC_ENVIRONMENT:dev}
    tests: COVERAGE_FILE = {env:COVERAGE_FILE:.coverage.{envname}}
passenv =
    HOME
    PYTEST_ADDOPTS
    dev: DEBUG
    dev: SENTRY_DSN
    dev: NEW_RELIC_LICENSE_KEY
deps =
    dev: ipython
    format,checkformatting: black
    format,checkformatting: isort
    lint: toml
    lint: pylint>=3.0.0
    lint: pydocstyle
    lint: pycodestyle
    lint,tests: pytest-mock
    lint,tests,functests: pytest
    lint,tests,functests: h-testkit
    tests: pytest-cov
    coverage: coverage[toml]
    lint,tests,functests: factory-boy
    lint,tests,functests: pytest-factoryboy
    lint,tests,functests: h-matchers
    lint,template: cookiecutter
    typecheck: mypy
depends =
    coverage: tests,py{311,310,39}-tests
commands =
    dev: {posargs:ipython --classic --no-banner --no-confirm-exit}
    format: black src tests bin
    format: isort --atomic src tests bin
    checkformatting: black --check src tests bin
    checkformatting: isort --quiet --check-only src tests bin
    lint: pylint src bin
    lint: pylint --rcfile=tests/pyproject.toml tests
    lint: pydocstyle src tests bin
    lint: pycodestyle src tests bin
    tests: python -m pytest --cov --cov-report= --cov-fail-under=0 {posargs:tests/unit/}
    functests: python -m pytest --failed-first --new-first --no-header --quiet {posargs:tests/functional/}
    coverage: coverage combine
    coverage: coverage report
    typecheck: mypy src
    template: python3 bin/make_template {posargs}