]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
py3: Port pure driver test to Python 3
authorVictor Stinner <vstinner@redhat.com>
Wed, 26 Aug 2015 22:13:51 +0000 (00:13 +0200)
committerVictor Stinner <vstinner@redhat.com>
Mon, 28 Sep 2015 15:56:37 +0000 (17:56 +0200)
* 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

cinder/tests/unit/test_pure.py
cinder/volume/drivers/pure.py
tox.ini

index 1f6725d0a82c55187c1a0822aa80cf4b1f841b0c..166907f72c324503aa1fe1117309186d5360fbfc 100644 (file)
@@ -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 =\
     {
index 5c47f7dcae7d700eda652dd6ea6135f6c6530f2b..eef8d598fcd860c258699ea53960ca90509daf2b 100644 (file)
@@ -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 1eb5fc02ad3f44c4c112b0f1ef4d68d5fd22bea7..3fb6a1c76da3afc576fc4db379d7029deb2df525 100644 (file)
--- 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 \