diff --git a/oslo_vmware/tests/test_service.py b/oslo_vmware/tests/test_service.py index 336ef0d0..e20f96dd 100644 --- a/oslo_vmware/tests/test_service.py +++ b/oslo_vmware/tests/test_service.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import io + import mock import requests import six @@ -500,16 +502,12 @@ class RequestsTransportTest(base.TestCase): if six.PY3: builtin_open = 'builtins.open' - open_mock = mock.MagicMock(name='file_handle', - spec=open) - import _io - file_spec = list(set(dir(_io.TextIOWrapper)).union( - set(dir(_io.BytesIO)))) else: builtin_open = '__builtin__.open' - open_mock = mock.MagicMock(name='file_handle', - spec=file) - file_spec = file + open_mock = mock.MagicMock(name='file_handle', + spec=open) + file_spec = list(set(dir(io.TextIOWrapper)).union( + set(dir(io.BytesIO)))) file_handle = mock.MagicMock(spec=file_spec) file_handle.write.return_value = None diff --git a/tox.ini b/tox.ini index 795d7f15..cd87fe97 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ minversion = 2.0 envlist = py35,py27,pep8 [testenv] +basepython = python3 install_command = pip install {opts} {packages} whitelist_externals = find rm @@ -12,6 +13,9 @@ deps = -r{toxinidir}/requirements.txt commands = python setup.py testr --slowest --testr-args='{posargs}' +[testenv:py27] +basepython = python2.7 + [testenv:pep8] commands = flake8 @@ -64,7 +68,6 @@ commands = pip-missing-reqs -d --ignore-module=oslo_vmware* --ignore-file=oslo_v commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html [testenv:lower-constraints] -basepython = python3 deps = -c{toxinidir}/lower-constraints.txt -r{toxinidir}/test-requirements.txt