]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Port test_quobyte to Python 3
authorVictor Stinner <vstinner@redhat.com>
Fri, 2 Oct 2015 15:25:50 +0000 (17:25 +0200)
committerVictor Stinner <vstinner@redhat.com>
Sat, 3 Oct 2015 00:07:46 +0000 (02:07 +0200)
Modify assertRaisesAndMessageMatches() to tolerate subclasses. On
Python 3, a permission error now raises an exception PermissionError
which is a subclass of OSError, whereas the test expected exactly the
OSError type.

Partial-Implements: blueprint cinder-python3
Change-Id: Ia232c27de6a67eafad30b25301531e292fe349dc

cinder/tests/unit/test_quobyte.py
tox.ini

index 12b774050097cd2a725b60ee54952bd5526d1796..ed91d4b3c731131d71ddc7d2c6f95d6667860492 100644 (file)
@@ -102,9 +102,9 @@ class QuobyteDriverTestCase(test.TestCase):
             callableObj(*args, **kwargs)
         except Exception as exc:
             caught = True
-            self.assertEqual(excClass, type(exc),
-                             'Wrong exception caught: %s Stacktrace: %s' %
-                             (exc, traceback.format_exc()))
+            self.assertIsInstance(exc, excClass,
+                                  'Wrong exception caught: %s Stacktrace: %s' %
+                                  (exc, traceback.format_exc()))
             self.assertIn(msg, six.text_type(exc))
 
         if not caught:
diff --git a/tox.ini b/tox.ini
index d86012f2008a58612f8d1e0d4c680411ec792319..11dac941d52cfa2c63b6b84123df7a3d622c76b5 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -84,6 +84,7 @@ commands =
     cinder.tests.unit.test_nimble \
     cinder.tests.unit.test_pure \
     cinder.tests.unit.test_qos_specs \
+    cinder.tests.unit.test_quobyte \
     cinder.tests.unit.test_quota \
     cinder.tests.unit.test_rbd \
     cinder.tests.unit.test_remotefs \