# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[tox]
minversion = 3.18
envlist =
    lint
    py27
    py27-zserver
    py35
    py36
    py37
    py38
    docs
    coverage

[testenv]
skip_install = true
# We need to pin setuptools until we have zc.buildout 3.0.
deps =
    setuptools < 52
    zc.buildout
commands_pre =
    {envbindir}/buildout -c {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install alltests
commands =
    {envdir}/bin/alltests {posargs:-vc}

[testenv:py27-zserver]
commands_pre =
    {envbindir}/buildout -c {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install zservertests
commands =
    {envdir}/bin/zservertests {posargs:-vc}

[testenv:autopep8]
basepython = python3
skip_install = true
deps =
    -cconstraints.txt
    autopep8
    docformatter
commands =
    autopep8 --verbose --in-place --recursive --aggressive --aggressive {toxinidir}/src setup.py
    docformatter --in-place --recursive {toxinidir}/src setup.py

[testenv:lint]
basepython = python3
allowlist_externals =
    mkdir
commands_pre =
    mkdir -p {toxinidir}/parts/flake8
commands =
    isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py
    flake8 {toxinidir}/src {toxinidir}/setup.py
    check-manifest
    check-python-versions
deps =
    check-manifest
    check-python-versions
    flake8
    isort
    # Useful flake8 plugins that are Python and Plone specific:
    flake8-coding
    flake8-debugger
    mccabe

[testenv:isort-apply]
basepython = python3
commands_pre =
deps =
    isort
commands =
    isort {toxinidir}/src {toxinidir}/setup.py []

[testenv:docs]
basepython = python3.8
skip_install = false
deps =
    jinja2
    Sphinx
extras =
    docs
commands_pre =
commands =
    sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html

[testenv:coverage]
basepython = python3
skip_install = true
allowlist_externals =
    mkdir
deps =
    {[testenv]deps}
    coverage
    coverage-python-version
commands =
    mkdir -p {toxinidir}/parts/htmlcov
    coverage run {envdir}/bin/alltests {posargs:-vc}
    coverage html
    coverage report -m --fail-under=80

[coverage:run]
branch = True
plugins = coverage_python_version
source = src

[coverage:report]
precision = 2
exclude_lines =
    pragma: no cover
    pragma: nocover
    except ImportError:
    raise NotImplementedError
    if __name__ == '__main__':
    self.fail
    raise AssertionError

[coverage:html]
directory = parts/htmlcov
