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.
This commit is contained in:
parent
26c28445a5
commit
97e7d95dd3
|
@ -69,7 +69,7 @@ confidence=
|
|||
# Arranged by category and use symbolic names instead of ids.
|
||||
disable=
|
||||
# Convention
|
||||
missing-docstring, invalid-name,
|
||||
missing-docstring, invalid-name, bad-continuation,
|
||||
# Error
|
||||
no-member, no-name-in-module,
|
||||
# Information
|
||||
|
|
16
.travis.yml
16
.travis.yml
|
@ -3,7 +3,7 @@ sudo: required
|
|||
|
||||
language: python
|
||||
python:
|
||||
- 2.7
|
||||
- 3.5
|
||||
cache: pip
|
||||
virtualenv:
|
||||
system_site_packages: true
|
||||
|
@ -16,8 +16,8 @@ matrix:
|
|||
include:
|
||||
- name: Unit tests - Python 2
|
||||
env: TOX_ENV=py27
|
||||
python: 2.7
|
||||
- name: Unit tests - Python 3
|
||||
python: 3.5
|
||||
env: TOX_ENV=py3
|
||||
- if: commit_message =~ SECURITY_TEST
|
||||
env: TOX_ENV=security
|
||||
|
@ -25,8 +25,9 @@ matrix:
|
|||
env: TOX_ENV=lint
|
||||
- name: Docs build
|
||||
env: TOX_ENV=docs
|
||||
- name: PyGTK unit tests
|
||||
env: TOX_ENV=pygtkui
|
||||
python: 2.7
|
||||
- name: GTK unit tests
|
||||
env: TOX_ENV=gtkui
|
||||
- name: Plugins unit tests
|
||||
env: TOX_ENV=plugins
|
||||
|
||||
|
@ -46,8 +47,9 @@ addons:
|
|||
# Install dependencies
|
||||
install:
|
||||
- pip install tox tox-venv
|
||||
- "if [ $TOX_ENV == 'pygtkui' ]; then
|
||||
sudo apt install python-gi python-gi-cairo gir1.2-gtk-3.0;
|
||||
- "if [ $TOX_ENV == 'gtkui' ]; then
|
||||
sudo apt install python-gi python-gi-cairo python3-gi python3-gi-cairo \
|
||||
gir1.2-gtk-3.0;
|
||||
fi"
|
||||
- "if [ $TOX_ENV == 'security' ]; then
|
||||
testssl_url=https://github.com/drwetter/testssl.sh/archive/v2.9.5-5.tar.gz;
|
||||
|
@ -59,7 +61,7 @@ before_script:
|
|||
- export PYTHONPATH=$PYTHONPATH:$PWD
|
||||
- python -c "import libtorrent as lt; print(lt.__version__)"
|
||||
# Start xvfb for the GTKUI tests
|
||||
- "if [ $TOX_ENV == 'pygtkui' ]; then
|
||||
- "if [ $TOX_ENV == 'gtkui' ]; then
|
||||
/sbin/start-stop-daemon --start --quiet --background \
|
||||
--make-pidfile --pidfile /tmp/custom_xvfb_99.pid \
|
||||
--exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16;
|
||||
|
|
|
@ -96,6 +96,7 @@ autodoc_mock_imports = [
|
|||
'libtorrent',
|
||||
'psyco',
|
||||
'gi',
|
||||
'cairo',
|
||||
'curses',
|
||||
'win32api',
|
||||
'win32file',
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
# isort:skip_file
|
||||
from __future__ import print_function
|
||||
|
||||
import glob
|
||||
|
@ -19,6 +19,7 @@ import re
|
|||
import shutil
|
||||
import sys
|
||||
|
||||
|
||||
import bbfreeze
|
||||
import gtk
|
||||
from win32verstamp import stamp
|
||||
|
|
|
@ -2,6 +2,7 @@ pytest
|
|||
pytest-twisted
|
||||
pytest-cov
|
||||
mock
|
||||
pre-commit
|
||||
flake8
|
||||
flake8-quotes
|
||||
flake8-isort
|
||||
|
|
|
@ -19,10 +19,8 @@ frameworks = CoreFoundation, Foundation, AppKit
|
|||
[isort]
|
||||
known_standard_library = future_builtins
|
||||
known_third_party =
|
||||
# Ignore Windows specific modules.
|
||||
bbfreeze, win32verstamp,
|
||||
# Ignore gtk modules, primarily for tox testing.
|
||||
pygtk, gtk, gobject, gtk.gdk, pango, cairo, pangocairo, gi
|
||||
cairo, gi,
|
||||
# Ignore other module dependencies for pre-commit isort.
|
||||
twisted, OpenSSL, pytest, recommonmark, chardet, pkg_resources, zope, mock,
|
||||
sphinx
|
||||
|
|
176
tox.ini
176
tox.ini
|
@ -5,45 +5,74 @@
|
|||
|
||||
[tox]
|
||||
envlist = py27, py3, lint, docs
|
||||
minversion=2.0
|
||||
|
||||
[base]
|
||||
deps =
|
||||
# Minimum pip version and setuptools to fix issue running on travis.
|
||||
pip>=10
|
||||
setuptools
|
||||
-rrequirements.txt
|
||||
|
||||
[testenv]
|
||||
install_command = {envpython} -m pip install --ignore-installed {opts} {packages}
|
||||
passenv = DISPLAY PYTHONPATH
|
||||
setenv = PYTHONPATH = {toxinidir}
|
||||
sitepackages = True
|
||||
deps =
|
||||
{[base]deps}
|
||||
-rrequirements-tests.txt
|
||||
commands =
|
||||
python -c "import libtorrent as lt; print(lt.__version__)"
|
||||
pytest -v -s -m "not (todo or gtkui or security)" deluge/tests
|
||||
minversion=3.0
|
||||
|
||||
[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 =
|
||||
pip>=10
|
||||
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 = python -m pip install --ignore-installed {opts} {packages}
|
||||
passenv = DISPLAY PYTHONPATH
|
||||
setenv =
|
||||
PYTHONPATH = {toxinidir}
|
||||
PYTEST_ADDOPTS = -v -s
|
||||
sitepackages = True
|
||||
deps = {[basetests]deps}
|
||||
commands =
|
||||
python -c "import libtorrent as lt; print(lt.__version__)"
|
||||
pytest -m "not (todo or gtkui or security)" deluge/tests
|
||||
|
||||
# ==========
|
||||
# Unit tests
|
||||
# ==========
|
||||
|
||||
[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 =
|
||||
|
|
Loading…
Reference in New Issue