[tox]
minversion = 3.18.0
envlist = py3,pep8
ignore_basepython_conflict = True

[testenv]
basepython = {env:TOX_PYTHON:python3}
usedevelop = True
setenv =
   VIRTUAL_ENV={envdir}
   PYTHONWARNINGS=default::DeprecationWarning
   OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
   OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
   OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
   PYTHONWARNINGS=default::DeprecationWarning,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site
install_command = pip install {opts} {packages}
deps =
  -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2023.1}
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt
  hacking>=3.0.1,<3.1.0 # Apache-2.0
commands = stestr run --slowest {posargs}

[testenv:pep8]
commands = flake8
           bash {toxinidir}/tools/coding-checks.sh --all '{posargs}'
deps =
  {[testenv]deps}
  pylint==2.5.3 # GPLv2
allowlist_externals = bash

[testenv:venv]
commands = {posargs}

[testenv:cover]
commands = python setup.py test --coverage --testr-args='{posargs}'

[testenv:docs]
deps =
  -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2023.1}
  -r{toxinidir}/doc/requirements.txt
commands =
  sphinx-build -W -b html -d doc/build/doctrees doc/source doc/build/html

[testenv:pdf-docs]
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
allowlist_externals =
  make
commands =
  sphinx-build -W -b latex doc/source doc/build/pdf
  make -C doc/build/pdf

[testenv:releasenotes]
deps =
  -r{toxinidir}/doc/requirements.txt
commands =
  sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

[testenv:debug]
commands = oslo_debug_helper {posargs}

[testenv:functional]
setenv = {[testenv]setenv}
         OS_TEST_PATH=./ovsdbapp/tests/functional
         OVN_SRCDIR={envdir}/src/ovn
         OVS_SRCDIR={envdir}/src/ovn/ovs
         VTEP_SRCDIR={envdir}src/ovn/ovs/vtep
         OVN_BRANCH={env:OVN_BRANCH:}
passenv = KEEP_VENV
commands =
         bash {toxinidir}/tools/setup-ovs.sh
         {[testenv]commands}
allowlist_externals = bash

[flake8]
# W504 line break after binary operator
ignore = W504
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality
# H205: Use assert(Greater|Less)(Equal) for comparison
# H904: Delay string interpolations at logging calls
enable-extensions=H106,H203,H204,H205,H904
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
import-order-style = pep8
