[tox]
envlist = isort,py27,py34,py35,py36,pypy,pypy3,flake8,manifest,docs,readme,changelog,coverage-report


[testenv]
# Prevent random setuptools/pip breakages like
# https://github.com/pypa/setuptools/issues/1042 from breaking our builds.
setenv =
    VIRTUALENV_NO_DOWNLOAD=1
extras = tests
commands = python -m pytest {posargs}


[testenv:py27]
extras = tests
commands = coverage run --parallel -m pytest {posargs}


[testenv:py36]
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
install_command = pip install --no-compile {opts} {packages}
setenv =
    PYTHONWARNINGS=d
extras = tests
commands = coverage run --parallel -m pytest {posargs}


# Uses default basepython otherwise reporting doesn't work on Travis where
# Python 3.6 is only available in 3.6 jobs.
[testenv:coverage-report]
deps = coverage
skip_install = true
commands =
    coverage combine
    coverage report


[testenv:flake8]
basepython = python3.6
extras = tests
# Needs a full install so isort can determine own/foreign imports.
deps =
    flake8
    flake8-isort
commands = flake8 src tests setup.py conftest.py docs/conf.py


[testenv:isort]
basepython = python3.6
extras = tests
# Needs a full install so isort can determine own/foreign imports.
deps =
    isort
commands =
    isort --recursive setup.py conftest.py src tests


[testenv:docs]
basepython = python3.6
setenv =
    PYTHONHASHSEED = 0
extras = docs
commands =
    sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
    sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
    python -m doctest README.rst


[testenv:manifest]
basepython = python3.6
deps = check-manifest
skip_install = true
commands = check-manifest


[testenv:readme]
basepython = python3.6
deps = readme_renderer
skip_install = true
commands = python setup.py check -r -s


[testenv:changelog]
basepython = python3.6
deps = towncrier
skip_install = true
commands = towncrier --draft
