Browse Source

Fix Python 3 functional tests run

Cinderlib functional tests run fine on Python 2, but when run with
Python 3.6 we fail to import base_tests from test_basic and we also get
a dictionary changed size during iteration error.

This patch makes it possible to run functional tests on Python 3
versions.

Change-Id: Ib66b29102d58ab1600e206e205a70efa17b978f4
changes/33/695233/1
Gorka Eguileor 2 weeks ago
parent
commit
b74a3f04b3
2 changed files with 3 additions and 2 deletions
  1. +2
    -1
      cinderlib/tests/functional/base_tests.py
  2. +1
    -1
      cinderlib/tests/functional/test_basic.py

+ 2
- 1
cinderlib/tests/functional/base_tests.py View File

@@ -41,7 +41,8 @@ def set_backend(func, new_name, backend_name):
def test_all_backends(cls):
"""Decorator to run tests in a class for all available backends."""
config = BaseFunctTestCase.ensure_config_loaded()
for fname, func in cls.__dict__.items():
# Prevent dictionary changed size during iteration on Python 3
for fname, func in dict(vars(cls)).items():
if fname.startswith('test_'):
for backend in config['backends']:
bname = backend['volume_backend_name']

+ 1
- 1
cinderlib/tests/functional/test_basic.py View File

@@ -15,8 +15,8 @@

import os

import base_tests
import cinderlib
from cinderlib.tests.functional import base_tests


class BaseFunctTestCase(base_tests.unittest2.TestCase):

Loading…
Cancel
Save