From: Victor Stinner Date: Wed, 7 Oct 2015 13:43:05 +0000 (+0200) Subject: Port test_srb to Python 3 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3fda737f53824170bd59eb6e8ce2e991c89c3c1d;p=openstack-build%2Fcinder-build.git Port test_srb to Python 3 * Replace itertools.izip() with six.moves.zip() * Replace (int, long) with six.integer_types * tests-py3.txt: add cinder.tests.unit.test_srb Disable pylint on six.moves.zip() because pylint doesn't handle correctly six.moves, see: https://bitbucket.org/logilab/pylint/issues/200/ Partial-Implements: blueprint cinder-python3 Change-Id: I5ce550107ce5a72fee87e36bfb56a9794789b43a --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 283f2cb92..509086e46 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -17,7 +17,6 @@ LVM class for performing LVM operations. """ -import itertools import math import os import re @@ -26,6 +25,7 @@ from os_brick import executor from oslo_concurrency import processutils as putils from oslo_log import log as logging from oslo_utils import excutils +from six import moves from cinder import exception from cinder.i18n import _LE, _LI @@ -290,7 +290,8 @@ class LVM(executor.Executor): lv_list = [] if out is not None: volumes = out.split() - for vg, name, size in itertools.izip(*[iter(volumes)] * 3): + iterator = moves.zip(*[iter(volumes)] * 3) # pylint: disable=E1101 + for vg, name, size in iterator: lv_list.append({"vg": vg, "name": name, "size": size}) return lv_list diff --git a/cinder/tests/unit/test_srb.py b/cinder/tests/unit/test_srb.py index 03701b632..d790dae5f 100644 --- a/cinder/tests/unit/test_srb.py +++ b/cinder/tests/unit/test_srb.py @@ -17,6 +17,7 @@ import mock from oslo_concurrency import processutils from oslo_utils import units +import six from cinder import context from cinder import exception @@ -265,7 +266,7 @@ class SRBDriverTestCase(test.TestCase): @staticmethod def _convert_size(s): - if isinstance(s, (int, long)): + if isinstance(s, six.integer_types): return s try: diff --git a/tests-py3.txt b/tests-py3.txt index e933f6a31..d7a56090e 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -76,6 +76,7 @@ cinder.tests.unit.test_scality cinder.tests.unit.test_service cinder.tests.unit.test_sheepdog cinder.tests.unit.test_smbfs +cinder.tests.unit.test_srb cinder.tests.unit.test_solidfire cinder.tests.unit.test_test cinder.tests.unit.test_test_utils