make python 3 the default for tox.ini

This patch is part of the community goals to enable python 3 first, and
only use python 2 when explict.

To do so, this patch:
- Makes python 3 the default env for non py27 tox targets.
- Addresses any py3 changes in the code.

Change-Id: Iab52979bb720a8df8924108093e5119922622cb9
This commit is contained in:
Boden R 2018-06-19 11:38:01 -06:00
parent 716527fb20
commit ab3822413e
2 changed files with 6 additions and 3 deletions

View File

@ -26,7 +26,7 @@ setenv = {[testenv]setenv}
commands = false
[testenv:functional]
basepython = python2.7
basepython = python3
setenv = {[testenv]setenv}
{[testenv:common]setenv}
OS_TEST_PATH=./vmware_nsxlib/tests/functional
@ -36,7 +36,7 @@ deps =
-r{toxinidir}/vmware_nsxlib/tests/functional/requirements.txt
[testenv:dsvm-functional]
basepython = python2.7
basepython = python3
setenv = {[testenv]setenv}
OS_SUDO_TESTING=1
OS_FAIL_ON_MISSING_DEPS=1
@ -53,6 +53,7 @@ sitepackages = True
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:pep8]
basepython = python3
deps =
{[testenv]deps}
commands =
@ -69,6 +70,7 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/re
commands = bandit -r vmware_nsxlib -n 5 -ll
[testenv:cover]
basepython = python3
commands =
python setup.py test --coverage --coverage-package-name=vmware_nsxlib --testr-args='{posargs}'
coverage report
@ -77,6 +79,7 @@ commands =
commands = {posargs}
[testenv:docs]
basepython = python3
commands = sphinx-build -W -b html doc/source doc/build/html
[flake8]

View File

@ -42,7 +42,7 @@ class NsxLibException(Exception):
if six.PY2:
def __unicode__(self):
return unicode(self.msg)
return unicode(self.msg) if six.PY2 else self.msg # noqa
def __str__(self):
return self.msg