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
This commit is contained in:
Victor Stinner 2015-10-07 15:43:05 +02:00
parent 686db70dfd
commit 3fda737f53
3 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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:

View File

@ -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