[tox]
envlist = about
          autopep8
          docformatter
          isort
          pylint
          flake8
          flake8_tests
          pydocstyle
          sphinx
          py{26,27,34,35,36,37,38}
skip_missing_interpreters = true

[testenv]
passenv = TEST_QUICK TEST_KEYBOARD TEST_RAW
basepython = python3.8
deps = pytest==5.3.2
       pytest-cov==2.8.1
       pytest-xdist==1.31.0
       mock==3.0.5
commands = {envpython} -m pytest --cov-config={toxinidir}/tox.ini {posargs:\
             --strict --verbose \
             --junit-xml=.tox/results.{envname}.xml \
             --durations=3 \
             } \
          --log-format='%(levelname)s %(relativeCreated)2.2f %(filename)s:%(lineno)d %(message)s' \
          tests

[pytest]
looponfailroots = blessed
norecursedirs = .git .tox build
addopts = --disable-pytest-warnings
          --cov-append --cov-report=html --color=yes --ignore=setup.py --ignore=.tox
          --cov=blessed
filterwarnings =
    error
junit_family = xunit1

[coverage:run]
branch = True
source = blessed
parallel = True

[coverage:report]
omit = tests/*
exclude_lines = pragma: no cover
precision = 1

[coverage:paths]
source = blessed/

[isort]
line_length = 100
indent = '    '
multi_line_output = 1
length_sort = 1
import_heading_stdlib = std imports
import_heading_thirdparty = 3rd party
import_heading_firstparty = local
import_heading_localfolder = local
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
no_lines_before=LOCALFOLDER
known_third_party = jinxed
atomic = true

[flake8]
max-line-length = 100
exclude = .tox,build
deps = flake8==3.7.9

[pydocstyle]
ignore = D101,  # Missing docstring in public class
         D105,  # Missing docstring in magic method
         D203,  # 1 blank line required before class docstring
         D204,  # 1 blank line required after class docstring
         D212,  # Multi-line docstring summary should start at the first line
         D401  # First line should be in imperative mood

[doc8]
max-line-length = 100

[testenv:py26]
setenv = TEST_QUICK=1
basepython = python2.6
deps = pytest==3.2.5
       pytest-cov==2.5.1
       pytest-xdist==1.20.1
       mock==2.0.0
commands = {envpython} -m pytest --cov-config={toxinidir}/tox.ini {posargs:\
             --strict --verbose \
             --junit-xml=.tox/results.{envname}.xml \
             --durations=3 \
             } \
          tests

[testenv:py27]
basepython = python2.7
setenv = TEST_KEYBOARD = {env:TEST_KEYBOARD:yes}
deps = pytest==4.6.9
       pytest-cov==2.8.1
       pytest-xdist==1.31.0
       mock==3.0.5

[testenv:py34]
setenv = TEST_QUICK=1
basepython = python3.4
deps = pytest==4.6.9
       pytest-cov==2.8.1
       pytest-xdist==1.31.0
       mock==3.0.5

[testenv:py35]
setenv = TEST_QUICK=1
basepython = python3.5

[testenv:py36]
setenv = TEST_QUICK=1
basepython = python3.6

[testenv:py37]
setenv = TEST_QUICK=1
basepython = python3.7

[testenv:py38]
basepython = python3.8
deps = {[testenv]deps}
       pytest-rerunfailures==8.0
setenv = TEST_KEYBOARD = {env:TEST_KEYBOARD:yes}
commands = {envbindir}/py.test --cov-config={toxinidir}/tox.ini \
             {posargs:\
                 --reruns 5  \
                 --strict --verbose \
                 --junit-xml=.tox/results.{envname}.xml \
                 --durations=3 \
             } \
          tests

[testenv:py39]
setenv = TEST_QUICK=1
basepython = python3.9

[testenv:develop]
commands = {posargs}

[testenv:about]
commands = python {toxinidir}/bin/display-sighandlers.py
           python {toxinidir}/bin/display-terminalinfo.py
           python {toxinidir}/bin/display-fpathconf.py

[testenv:autopep8]
deps = autopep8==1.4.4
commands =
    {envbindir}/autopep8 \
        --in-place \
        --recursive \
        --aggressive \
        --aggressive \
        blessed/ bin/ setup.py

[testenv:docformatter]
deps =
    docformatter==1.3.1
    untokenize==0.1.1
commands =
    {envbindir}/docformatter \
        --in-place \
        --recursive \
        --pre-summary-newline \
        --wrap-summaries=100 \
        --wrap-descriptions=100 \
        {toxinidir}/blessed/ \
        {toxinidir}/bin \
        {toxinidir}/setup.py \
        {toxinidir}/docs/conf.py

[testenv:isort]
deps = {[testenv]deps}
       -r docs/requirements.txt
       isort==4.3.21
commands = {envbindir}/isort --quiet --apply --recursive

[testenv:pylint]
deps = pylint==2.4.4
commands = {envbindir}/pylint --rcfile={toxinidir}/.pylintrc \
           --ignore=tests,docs,setup.py,conf.py,build,distutils,.pyenv,.git,.tox \
           {posargs:{toxinidir}}/blessed

[testenv:flake8]
deps = {[flake8]deps}
commands = {envbindir}/flake8 --exclude=tests,docs/sphinxext/github.py setup.py docs/ blessed/ bin/

[testenv:flake8_tests]
deps = {[flake8]deps}
commands = {envbindir}/flake8 --ignore=W504,F811,F401 tests/

[testenv:pydocstyle]
deps = pydocstyle==3.0.0
       restructuredtext_lint
       doc8
       pygments
commands = {envbindir}/pydocstyle --source --explain {toxinidir}/blessed
           {envbindir}/rst-lint README.rst
           {envbindir}/doc8 --ignore-path docs/_build --ignore D000 docs

[testenv:sphinx]
deps = -r {toxinidir}/docs/requirements.txt
commands = {envbindir}/sphinx-build {posargs:-v -W -d {toxinidir}/docs/_build/doctrees -b html docs {toxinidir}/docs/_build/html}

[testenv:linkcheck]
deps = -r {toxinidir}/docs/requirements.txt
commands = {envbindir}/sphinx-build -v -W -d {toxinidir}/docs/_build/doctrees -b linkcheck docs docs/_build/linkcheck

[testenv:codecov]
basepython = python{env:TOXPYTHON:{env:TRAVIS_PYTHON_VERSION:3.8}}
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_*
deps = codecov>=1.4.0
# commands = codecov -e TOXENV
# Workaround for https://github.com/codecov/codecov-python/issues/158
commands = {envpython} run_codecov.py -e TOXENV

[testenv:publish_static]
# Synchronize the artifacts in docs/_static/ with https://dxtz6bzwq9sxx.cloudfront.net/
deps = awscli
commands = aws s3 sync --exclude '*.DS_Store*' --delete --acl=public-read \
           docs/_static/ s3://python-blessed/
