From 2ea552e019bd427b5b1709160a6ed7da9dd23fbd Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Mon, 10 Dec 2018 11:22:54 +0000 Subject: [PATCH] Add python 3.7 unit and functional tox jobs Without these, if you try to run tox -epy37,functional-py37 you'll get a successful tox run, but no actual tests are run, which is rather misleading. Given the generaly availability of python 3.7 this is a bad thing. Running the tests under python 3.7 identified a few minor tests failures, also fixed here. Each is a result of a change in behavior in python 3.7: * printable unicode changes with a new Unicode 11-based unicodedata package * intentionally raising StopIteration in a generator is now considered a RuntimeError, 'return' should be used instead * an exception message is different beween python 3 and python 2, and the guard for it was mapping python 3.5 and 3.6 but not 3.7. zuul configuration is adjusted to add an experimental job for python 3.7 unit. A functional test job is not added, because we don't have 3.6 yet, and we probably want to get through that first. Closes-Bug: #1807976 Closes-Bug: #1807970 Change-Id: I37779a12d3b36eb3dc7e2733d07fe0ed23ab3da6 --- .zuul.yaml | 1 + nova/compute/multi_cell_list.py | 4 ++-- nova/tests/unit/test_api_validation.py | 2 +- nova/tests/unit/test_flavors.py | 4 ++-- tox.ini | 13 +++++++++++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 86bf1158c06f..db574693ca6f 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -266,3 +266,4 @@ irrelevant-files: *dsvm-irrelevant-files - os-vif-ovs: irrelevant-files: *dsvm-irrelevant-files + - openstack-tox-py37 diff --git a/nova/compute/multi_cell_list.py b/nova/compute/multi_cell_list.py index 4975d49688a0..0fd208bf972c 100644 --- a/nova/compute/multi_cell_list.py +++ b/nova/compute/multi_cell_list.py @@ -105,13 +105,13 @@ def query_wrapper(ctx, fn, *args, **kwargs): # we won't call into the implementation's comparison routines) # wrapping the sentinel indicating timeout. yield RecordWrapper(ctx, None, context.did_not_respond_sentinel) - raise StopIteration + return except Exception as e: # Here, we yield a RecordWrapper (no sort_ctx needed since # we won't call into the implementation's comparison routines) # wrapping the exception object indicating failure. yield RecordWrapper(ctx, None, e.__class__(e.args)) - raise StopIteration + return @six.add_metaclass(abc.ABCMeta) diff --git a/nova/tests/unit/test_api_validation.py b/nova/tests/unit/test_api_validation.py index db202276c899..bb2e74ab2a4f 100644 --- a/nova/tests/unit/test_api_validation.py +++ b/nova/tests/unit/test_api_validation.py @@ -467,7 +467,7 @@ class PatternPropertiesTestCase(APIValidationTestCase): # Note(jrosenboom): This is referencing an internal python error # string, which is no stable interface. We need a patch in the # jsonschema library in order to fix this properly. - if sys.version[:3] in ['3.5', '3.6']: + if sys.version[:3] in ['3.5', '3.6', '3.7']: detail = "expected string or bytes-like object" else: detail = "expected string or buffer" diff --git a/nova/tests/unit/test_flavors.py b/nova/tests/unit/test_flavors.py index bfaacbb708dd..d237e3d2147d 100644 --- a/nova/tests/unit/test_flavors.py +++ b/nova/tests/unit/test_flavors.py @@ -187,8 +187,8 @@ class CreateInstanceTypeTest(test.TestCase): self.assertInvalidInput('foobar\x00', 64, 1, 120) def test_name_with_non_printable_characters(self): - # Names cannot contain printable characters - self.assertInvalidInput(u'm1.\u0868 #', 64, 1, 120) + # Names cannot contain non printable characters + self.assertInvalidInput(u'm1.\u0C77 #', 64, 1, 120) def test_name_length_checks(self): MAX_LEN = 255 diff --git a/tox.ini b/tox.ini index e3e88f6ab7df..d68313785794 100644 --- a/tox.ini +++ b/tox.ini @@ -52,6 +52,12 @@ basepython = python3.6 commands = {[testenv:py35]commands} +[testenv:py37] +# TODO(efried): Remove this once https://github.com/tox-dev/tox/issues/425 is fixed. +basepython = python3.7 +commands = + {[testenv:py35]commands} + [testenv:pep8] description = Run style checks. @@ -105,6 +111,13 @@ setenv = {[testenv]setenv} commands = {[testenv:functional]commands} +[testenv:functional-py37] +basepython = python3.7 +envdir = {toxworkdir}/py37 +setenv = {[testenv]setenv} +commands = + {[testenv:functional]commands} + [testenv:api-samples] envdir = {toxworkdir}/shared setenv =