summaryrefslogtreecommitdiffstats
path: root/tox.ini
diff options
context:
space:
mode:
authorCalum Lind <calumlind@gmail.com>2018-10-25 15:02:53 +0100
committerCalum Lind <calumlind@gmail.com>2018-11-02 08:47:57 +0000
commit97e7d95dd3cf9e922db147d49f23c931ad692c31 (patch)
treeda132daaf6c8e569aa9d525a7b81a9049173ebf3 /tox.ini
parent26c28445a5f89fe883aa6becae3e87d71ed3f589 (diff)
downloaddeluge-97e7d95dd3cf9e922db147d49f23c931ad692c31.tar.gz
deluge-97e7d95dd3cf9e922db147d49f23c931ad692c31.tar.bz2
deluge-97e7d95dd3cf9e922db147d49f23c931ad692c31.zip
Cleanup tox configuration
There were issues with dependencies and tox environments under Python 3 so refactored the tox configuration to be more consistent and clearer. - Moved travis to default to Python 3 for linting and tests. - Fixed missing mock for cairo in sphinx config. - Collated the base deps sections to improve readability. - Added PYTEST_ADDOPTS env to override pytest verbosity in just tox tests as this was a common option being used. - Renamed env 'testcoverage' to the more concise 'coverage' and moved html creation under single env as handy to have this output as well as report. - Cleaned up the isort config for gtk3. - Added `bad-continuation` to pylint config as conflcts with black formatting. - Fix isort issue with bbfreeze script. This will likely be removed in future so just skip sorting it.
Diffstat (limited to 'tox.ini')
-rw-r--r--tox.ini166
1 files changed, 78 insertions, 88 deletions
diff --git a/tox.ini b/tox.ini
index 134cde2a6..cb24c5547 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,31 +5,60 @@
[tox]
envlist = py27, py3, lint, docs
-minversion=2.0
+minversion=3.0
-[base]
+[pytest]
+# Hide logged warnings and errors in test output.
+log_cli_level = CRITICAL
+addopts = -p no:warnings --basetemp=_pytest_temp
+
+# =================
+# Base dependencies
+# =================
+[basesetup]
+# Minimum pip and setuptools versions to fix system and travis issues.
deps =
-# Minimum pip version and setuptools to fix issue running on travis.
pip>=10
- setuptools
+ setuptools>=40
+
+[basetests]
+deps =
+ {[basesetup]deps}
+ -rrequirements.txt
+ -rrequirements-tests.txt
+
+[baselint]
+deps =
+ {[basesetup]deps}
+ -rrequirements-tests.txt
+
+[basedev]
+deps =
+ {[basesetup]deps}
-rrequirements.txt
+ -rrequirements-dev.txt
+ -rrequirements-tests.txt
+
+[basedocs]
+deps =
+ {[basesetup]deps}
+ -rrequirements-docs.txt
+
+# ======================
+# Test environment setup
+# ======================
[testenv]
-install_command = {envpython} -m pip install --ignore-installed {opts} {packages}
+install_command = python -m pip install --ignore-installed {opts} {packages}
passenv = DISPLAY PYTHONPATH
-setenv = PYTHONPATH = {toxinidir}
+setenv =
+ PYTHONPATH = {toxinidir}
+ PYTEST_ADDOPTS = -v -s
sitepackages = True
-deps =
- {[base]deps}
- -rrequirements-tests.txt
+deps = {[basetests]deps}
commands =
python -c "import libtorrent as lt; print(lt.__version__)"
- pytest -v -s -m "not (todo or gtkui or security)" deluge/tests
-
-[pytest]
-# Hide logged warnings and errors in test output.
-log_cli_level = CRITICAL
-addopts = -p no:warnings --basetemp=_pytest_temp
+ pytest -m "not (todo or gtkui or security)" deluge/tests
# ==========
# Unit tests
@@ -37,13 +66,13 @@ addopts = -p no:warnings --basetemp=_pytest_temp
[testenv:security]
setenv = SECURITY_TESTS = True
-commands = pytest -v -s -m "security" deluge/tests/
+commands = pytest -m "security" deluge/tests
-[testenv:pygtkui]
-commands = pytest -v -s -m "gtkui" deluge/tests
+[testenv:gtkui]
+commands = pytest -m "gtkui" deluge/tests
[testenv:todo]
-commands = pytest -v -s -m "todo" deluge/tests
+commands = pytest -m "todo" deluge/tests
[testenv:trial]
setenv = {[testenv]setenv}{:}{toxinidir}/deluge/tests
@@ -55,56 +84,44 @@ commands =
setenv = PYTHONPATH = {toxinidir}{:}{toxinidir}/deluge/plugins
commands =
python setup.py build_plugins --develop --install-dir={toxinidir}/deluge/plugins/
- pytest -v -s -m "not gtkui" deluge/plugins
+ pytest -m "not gtkui" deluge/plugins
[testenv:pluginsgtkui]
setenv = PYTHONPATH = {toxinidir}{:}{toxinidir}/deluge/plugins
commands =
python setup.py build_plugins --develop --install-dir={toxinidir}/deluge/plugins/
- pytest -v -s deluge/plugins
+ pytest deluge/plugins
-
-# =======================
+# ============
# Code linting
-# =======================
+# ============
+
+# Disable site-packages to avoid using system installed commands.
[testenv:lint]
+sitepackages = False
passenv = HOMEPATH SSH_AUTH_SOCK
-deps =
- pre-commit
-commands =
- pre-commit run --all-files
+deps = {[baselint]deps}
+commands = pre-commit run --all-files
[testenv:flake8]
-# Disable site packages to avoid using system flake8 which uses
-# hardcoded python path which imports the wrong libraries.
sitepackages = False
-deps =
- {[testenv]deps}
- flake8
- flake8-quotes
- flake8-isort
- pep8-naming
+deps = {[baselint]deps}
commands =
flake8 --version
python -c 'import isort; print(isort.__version__)'
- flake8
+ flake8 *.py deluge
[testenv:flake8-complexity]
sitepackages = False
-deps =
- {[testenv:flake8]deps}
- mccabe
+deps = {[baselint]deps}
commands = flake8 --exit-zero --max-complexity 15 deluge
-
[testenv:pylint]
-# Disable site packages to avoid using system installed version
+
sitepackages = False
ignore_errors = True
-deps =
- {[testenv]deps}
- pylint
+deps = {[baselint]deps}
commands =
pylint --version
pylint deluge
@@ -112,63 +129,40 @@ commands =
python -m pylint *.py deluge/scripts/*.py
python -m pylint deluge/plugins/*/deluge/
+# ========
+# Coverage
+# ========
-# =============
-# Test coverage
-# =============
+[coveragebase]
+commands = coverage run --branch --source=deluge -m pytest -m "not todo" deluge/tests
-[testcoveragebase]
-deps =
- {[testenv]deps}
- pytest-cov
- coverage
-commands = coverage run --branch --source=deluge -m pytest -m "not todo" deluge/tests/
-
-[testenv:testcoverage]
-setenv = {[testenv]setenv}
-deps = {[testcoveragebase]deps}
+[testenv:coverage]
commands =
- {[testcoveragebase]commands}
- coverage report
-
-[testenv:testcoverage-html]
-setenv = {[testenv]setenv}
-deps = {[testcoveragebase]deps}
-commands =
- {[testcoveragebase]commands}
+ {[coveragebase]commands}
coverage html -d docs/build/htmlcoverage
-
+ coverage report
# ===================
# Documentation build
# ===================
-# We do not have all dependencies on RTD and travis so we exclude the
-# site packages (sitepackages=False) when building docs so that local
-# tests have a similar environment.
-
-[docsbase]
-sitepackages = False
-changedir = docs
-deps =
- -rrequirements-docs.txt
-
[testenv:docs]
basepython = python2.7
-sitepackages = {[docsbase]sitepackages}
+# Exclude site-packages so local builds have a similar environment to ReadTheDocs.
+sitepackages = False
skip_install = True
-deps = {[docsbase]deps}
+deps = {[basedocs]deps}
commands =
python setup.py clean_docs
sphinx-build -v -j auto -E -T -b html -d docs/build/doctrees docs/source docs/build/html
[testenv:docscoverage]
basepython = python2.7
-sitepackages = {[docsbase]sitepackages}
+sitepackages = False
skip_install = True
-changedir = {[docsbase]changedir}
+changedir = docs
deps =
- {[docsbase]deps}
+ {[basedocs]deps}
pytest-cov
whitelist_externals = mkdir
commands =
@@ -176,24 +170,20 @@ commands =
sphinx-build -W -b coverage -d build/doctrees source build/doccoverage
pytest --doctest-glob='*.rst'
-
# ========================
# Development Environment
# ========================
-[basedev]
-usedevelop = True
-deps = -rrequirements-dev.txt
[testenv:denv2]
basepython = python2.7
envdir = .venv2
-usedevelop = {[basedev]usedevelop}
+usedevelop = True
deps = {[basedev]deps}
commands =
[testenv:denv3]
basepython = python3
envdir = .venv3
-usedevelop = {[basedev]usedevelop}
+usedevelop = True
deps = {[basedev]deps}
commands =