From: Victor Stinner Date: Wed, 26 Aug 2015 22:13:51 +0000 (+0200) Subject: py3: Port pure driver test to Python 3 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3a1c8719273d1c872227aab48daa5741569e6284;p=openstack-build%2Fcinder-build.git py3: Port pure driver test to Python 3 * Replace func.func_name with func.__name__: the func_name attribute was removed in Python 3, whereas the __name__ attribute exists on Python 2 and Python 3 * Create INITIATOR_TARGET_MAP using list(set()) to get the same order than the tested code. The exact order is not reliable, it depends on the hash function which is now randomized by default on Python 3. The hash function is also different between Python 2.7 and 3.4. * tox.ini: add test_pure to Python 3.4 Blueprint cinder-python3 Change-Id: I78601278259f1d34ad6ac3458d2dd0a3aca9d77a --- diff --git a/cinder/tests/unit/test_pure.py b/cinder/tests/unit/test_pure.py index 1f6725d0a..166907f72 100644 --- a/cinder/tests/unit/test_pure.py +++ b/cinder/tests/unit/test_pure.py @@ -106,10 +106,9 @@ TARGET_WWN = "21000024ff59fe94" TARGET_PORT = "3260" INITIATOR_TARGET_MAP =\ { - '5001500150015081': ['21000024ff59fe93', - '21000024ff59fe92', - '21000024ff59fe91', - '21000024ff59fe94'], + # _build_initiator_target_map() calls list(set()) on the list, + # we must also call list(set()) to get the exact same order + '5001500150015081': list(set(FC_WWNS)), } DEVICE_MAPPING =\ { diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index 5c47f7dca..eef8d598f 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -71,7 +71,7 @@ def log_debug_trace(f): def wrapper(*args, **kwargs): cls_name = args[0].__class__.__name__ method_name = "%(cls_name)s.%(method)s" % {"cls_name": cls_name, - "method": f.func_name} + "method": f.__name__} LOG.debug("Enter " + method_name) result = f(*args, **kwargs) LOG.debug("Leave " + method_name) diff --git a/tox.ini b/tox.ini index 1eb5fc02a..3fb6a1c76 100644 --- a/tox.ini +++ b/tox.ini @@ -81,6 +81,7 @@ commands = cinder.tests.unit.test_netapp_nfs \ cinder.tests.unit.test_nfs \ cinder.tests.unit.test_nimble \ + cinder.tests.unit.test_pure \ cinder.tests.unit.test_qos_specs \ cinder.tests.unit.test_quota \ cinder.tests.unit.test_rbd \