]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port test_srb to Python 3
authorVictor Stinner <vstinner@redhat.com>
Wed, 7 Oct 2015 13:43:05 +0000 (15:43 +0200)
committerVictor Stinner <vstinner@redhat.com>
Thu, 8 Oct 2015 10:33:40 +0000 (12:33 +0200)
* 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

cinder/brick/local_dev/lvm.py
cinder/tests/unit/test_srb.py
tests-py3.txt

index 283f2cb92957609020565f49489fc27cb67125a1..509086e46e71d5bcea9b4c01efc67238f82e239b 100644 (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
index 03701b63235b629a55596ab76bc82482572d42a7..d790dae5fbccd4a7e8abbada5404ea61898f2ec6 100644 (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:
index e933f6a316be8899b3b6293e357bafaf33932538..d7a56090e0e953ad93b712c688269e4d89f07a09 100644 (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