horizon/tox.ini
Ivan Kolodyazhny 43f8c3b1f5 Switch integration tests to run with python3
tox env for the integration tests is now renamed to 'integration'
as it is no longer run under python 2.7.

__hash__() method is now defined in integration_tests.helpers.BaseTestCase
to avoid unhashable error during loading django test runner. This is
originally caused by the fact that the base testcase class for integration
tests is implemented on top of testtools and testtools does not define
__hash__() method. In Python 3, __hash__() method must be defined
if a class (re)defines __eq__() method to make the class hashable [1].
Ideally integration base TestCase class can be implemented on top of
Django test case, but the current implementation depends on features
from testtools a lot, so it seems better to add __hash__() method
as a workaround.

Unbound methods don't exist in Python 3[2], so six.create_unbound_method
doesn' work as expected. To dynamic method generation we have to use new
descriptors interface [3] or just generate new
functools.partialmethod [4] function introduced in Python 3.4 to
generate class methods with pre-defined 'path' argument and pass 'self'
as a first function argument for class instance.

[1] https://docs.python.org/3.5/reference/datamodel.html#object.__hash__
[2] https://six.readthedocs.io/#six.create_unbound_method
[3] https://docs.python.org/3/howto/descriptor.html
[4] https://docs.python.org/3/library/functools.html#functools.partialmethod

Change-Id: I5c3078bdc66e33fe676d431bb28d92b35faaf479
2019-03-05 09:10:01 +00:00

216 lines
6.2 KiB
INI

[tox]
envlist = pep8,py27,py35,py3-dj111,releasenotes,npm
minversion = 2.3.2
skipsdist = True
[testenv]
install_command = pip install {opts} {packages}
usedevelop = True
setenv =
VIRTUAL_ENV={envdir}
whitelist_externals =
bash
find
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands = {[unit_tests]commands}
[unit_tests]
commands =
find . -type f -name "*.pyc" -delete
bash {toxinidir}/tools/unit_tests.sh {envpython} {toxinidir} {posargs}
[testenv:py35]
setenv =
PYTHONUNBUFFERED = 1
{[testenv]setenv}
[testenv:py3-dj21]
basepython = python3
commands =
pip install django>=2.1<2.2
{[unit_tests]commands}
[testenv:py3-dj111]
basepython = python3
commands =
pip install django>=1.11,<2
{[unit_tests]commands}
[testenv:lower-constraints]
basepython = python3
deps =
-c{toxinidir}/lower-constraints.txt
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:pep8]
basepython = python3
# NOTE: Due to doc dependencies, we don't share envdir with "venv".
# sphinx (precisely Pygments) needs to be installed to make doc8 work properly
deps =
{[testenv]deps}
-r{toxinidir}/doc/requirements.txt
setenv =
{[testenv]setenv}
DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings
commands =
flake8 {posargs}
{envpython} {toxinidir}/manage.py extract_messages --verbosity 0 --check-only
bash {toxinidir}/tools/find_executables.sh
doc8 doc/source releasenotes/source releasenotes/notes
pylint -j 4 --verbose --rcfile=.pylintrc -f colorized openstack_dashboard openstack_auth horizon
[testenv:cover]
basepython = python3
envdir = {toxworkdir}/venv
commands =
coverage erase
coverage run {toxinidir}/manage.py test horizon --settings=horizon.test.settings {posargs}
coverage run -a {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings --exclude-tag integration {posargs}
coverage run -a {toxinidir}/manage.py test openstack_auth --settings=openstack_auth.tests.settings {posargs}
coverage xml
coverage html
[testenv:selenium]
basepython = python3
envdir = {toxworkdir}/venv
setenv =
{[testenv]setenv}
WITH_SELENIUM=1
SKIP_UNITTESTS=1
commands = {[unit_tests]commands}
[testenv:selenium-headless]
basepython = python3
envdir = {toxworkdir}/venv
setenv =
{[testenv]setenv}
SELENIUM_HEADLESS=1
WITH_SELENIUM=1
SKIP_UNITTESTS=1
commands = {[unit_tests]commands}
[testenv:selenium-phantomjs]
basepython = python3
envdir = {toxworkdir}/venv
setenv =
{[testenv]setenv}
SELENIUM_PHANTOMJS=1
WITH_SELENIUM=1
SKIP_UNITTESTS=1
commands = {[unit_tests]commands}
[testenv:integration]
basepython = python3
envdir = {toxworkdir}/venv
# Run integration tests only
passenv = AVCONV_INSTALLED
setenv =
PYTHONHASHSEED=0
INTEGRATION_TESTS=1
SELENIUM_HEADLESS=1
commands = {envpython} {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings --verbosity 2 --tag integration {posargs}
[testenv:npm]
basepython = python3
passenv =
HOME
DISPLAY
commands =
nodeenv -p
npm install
npm run {posargs:test}
[testenv:tests_system_packages]
basepython = python3
# Provide an environment for system packagers that dont want anything from pip
# Any extra deps needed for this env can be passed by setting TOX_EXTRA_DEPS
sitepackages = True
passenv = TOX_EXTRA_DEPS http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
# Sets deps to an empty list so nothing is installed from pip
deps =
commands =
pip install -U {env:TOX_EXTRA_DEPS:}
{[unit_tests]commands}
[testenv:docs]
basepython = python3
# We need to install horizon dependecies to build module references
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
commands =
sphinx-build -W -b html doc/source doc/build/html
[testenv:releasenotes]
basepython = python3
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
commands =
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:manage]
basepython = python3
envdir = {toxworkdir}/venv
commands = {envpython} {toxinidir}/manage.py {posargs}
[testenv:runserver]
basepython = python3
envdir = {toxworkdir}/venv
commands = {envpython} {toxinidir}/manage.py runserver {posargs}
[testenv:bandit]
basepython = python3
envdir = {toxworkdir}/venv
commands = bandit -r horizon openstack_auth openstack_dashboard -n5 -x tests -ll
[testenv:bandit-baseline]
envdir = {toxworkdir}/venv
basepython = python3
commands = bandit-baseline -r horizon openstack_auth openstack_dashboard -n5 -x tests -ii -ll
[flake8]
filename = *.py,django.wsgi
exclude = .git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/*
# W504 line break after binary operator
# (W503 and W504 are incompatible and we need to choose one of them.
# Existing codes follows W503, so we disable W504.)
# F405 TEMPLATES may be undefined, or defined from star imports
# (because it is not easy to avoid this in openstack_dashboard.test.settings)
ignore = W504,F405
# Enable the following hacking rules which are disabled by default
# H106 Do not 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
max-complexity = 20
max_line_length = 80
# flake8-import-order configurations
import-order-style = pep8
application-import-names = horizon,openstack_dashboard
[hacking]
local-check-factory = horizon.hacking.checks.factory
[doc8]
# File extensions to check
extensions = .rst, .yaml
# Maximal line length should be 80 but we have some overlong lines.
# Let's not get far more in.
max-line-length = 80
# Disable some doc8 checks:
# D000: Check RST validity
# - cannot handle "none" for code-block directive
ignore = D000