make functional tests run on python 3

- This change updates sanitize_log_path to
  use replace instead of string.translate so that
  it works across both python 2.7 and python 3.
- This change modifies the functional tests to run under
  python 3 by default. A new functional-py27 env is
  also added.

Change-Id: Id8127ae68cb5aeebdba73bd14fc0481cd9b773d9
This commit is contained in:
Sean Mooney
2019-02-20 00:54:19 +00:00
parent 871590f626
commit 5ab2ee6ed0
2 changed files with 10 additions and 10 deletions

View File

@@ -18,7 +18,6 @@ import functools
import inspect import inspect
import os import os
import six import six
import string
import sys import sys
import eventlet.timeout import eventlet.timeout
@@ -74,8 +73,7 @@ def setup_logging():
def sanitize_log_path(path): def sanitize_log_path(path):
"""Sanitize the string so that its log path is shell friendly""" """Sanitize the string so that its log path is shell friendly"""
replace_map = string.maketrans(' ()', '-__') return path.replace(' ', '-').replace('(', '_').replace(')', '_')
return path.translate(replace_map)
# Test worker cannot survive eventlet's Timeout exception, which effectively # Test worker cannot survive eventlet's Timeout exception, which effectively

16
tox.ini
View File

@@ -1,9 +1,10 @@
[tox] [tox]
minversion = 2.0 minversion = 3.1.1
envlist = py37,py27,pep8 envlist = py37,py27,pep8
skipsdist = True skipsdist = True
[testenv] [testenv]
basepython = python3
usedevelop = True usedevelop = True
install_command = pip install -U {opts} {packages} install_command = pip install -U {opts} {packages}
setenv = setenv =
@@ -17,11 +18,9 @@ whitelist_externals = bash
commands = stestr run --black-regex ".tests.functional" {posargs} commands = stestr run --black-regex ".tests.functional" {posargs}
[testenv:pep8] [testenv:pep8]
basepython = python3
commands = flake8 commands = flake8
[testenv:venv] [testenv:venv]
basepython = python3
commands = {posargs} commands = {posargs}
deps = deps =
{env:CONSTRAINTS_OPT} {env:CONSTRAINTS_OPT}
@@ -29,29 +28,32 @@ deps =
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
[testenv:functional] [testenv:functional-py27]
basepython = python2.7 basepython = python2.7
setenv = setenv =
{[testenv]setenv} {[testenv]setenv}
commands = commands =
stestr run --black-regex ".tests.unit" '{posargs}' stestr run --black-regex ".tests.unit" '{posargs}'
[testenv:functional]
setenv =
{[testenv]setenv}
commands =
stestr run --black-regex ".tests.unit" '{posargs}'
[testenv:docs] [testenv:docs]
basepython = python3
deps = deps =
{env:CONSTRAINTS_OPT} {env:CONSTRAINTS_OPT}
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html commands = sphinx-build -W -b html doc/source doc/build/html
[testenv:releasenotes] [testenv:releasenotes]
basepython = python3
deps = deps =
{env:CONSTRAINTS_OPT} {env:CONSTRAINTS_OPT}
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:lower-constraints] [testenv:lower-constraints]
basepython = python3
deps = deps =
-c{toxinidir}/lower-constraints.txt -c{toxinidir}/lower-constraints.txt
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt