From d631ac0c971b66b577020033dc0a8486079e3533 Mon Sep 17 00:00:00 2001 From: "ChangBo Guo(gcb)" Date: Thu, 24 Nov 2016 10:11:19 +0800 Subject: [PATCH] Port xenapi test_vm_utils to Python 3 * we can't compare str and int in Python 3, and code make sure product_version must be a tuple of 3 integers[1], so we can remove invalid tests. * Set correct exception type to catch [1]https://github.com/openstack/nova/blob/3304115b73ace6b3336c4f80f70de4661d3b1ef6/nova/virt/xenapi/client/session.py#L173 Partially-Implements: blueprint goal-python35 Change-Id: I0ba1e1f2ef37ade9bdc6d19066e4a33a07246416 --- nova/tests/unit/virt/xenapi/test_vm_utils.py | 5 ++--- tests-py3.txt | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/nova/tests/unit/virt/xenapi/test_vm_utils.py b/nova/tests/unit/virt/xenapi/test_vm_utils.py index 8303f578bf..a42dfe9932 100644 --- a/nova/tests/unit/virt/xenapi/test_vm_utils.py +++ b/nova/tests/unit/virt/xenapi/test_vm_utils.py @@ -882,6 +882,7 @@ class UnplugVbdTestCase(VMUtilsTestBase): def test_unplug_vbd_raises_unexpected_error(self): session = stubs.get_fake_session() + session.XenAPI.Failure = fake.Failure vbd_ref = "vbd_ref" vm_ref = 'vm_ref' session.call_xenapi.side_effect = test.TestingException() @@ -1469,6 +1470,7 @@ class ScanSrTestCase(VMUtilsTestBase): def test_scan_sr_unknown_error_fails_once(self): session = mock.Mock() + session.XenAPI.Failure = fake.Failure session.call_xenapi.side_effect = test.TestingException self.assertRaises(test.TestingException, vm_utils._scan_sr, session, "sr_ref") @@ -2423,9 +2425,6 @@ class ResizeFunctionTestCase(test.NoDBTestCase): def test_empty(self): self._test_is_resize("", "") - def test_bad_version(self): - self._test_is_resize("XenServer", "asdf") - class VMInfoTests(VMUtilsTestBase): def setUp(self): diff --git a/tests-py3.txt b/tests-py3.txt index 3cbd262c54..d2940ad22a 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -1,8 +1,5 @@ nova.tests.unit.api.openstack.compute.test_user_data.ServersControllerCreateTest nova.tests.unit.test_wsgi.TestWSGIServerWithSSL -nova.tests.unit.virt.xenapi.test_vm_utils.ResizeFunctionTestCase -nova.tests.unit.virt.xenapi.test_vm_utils.ScanSrTestCase -nova.tests.unit.virt.xenapi.test_vm_utils.UnplugVbdTestCase ########################################################################## # NOTE(dims): The following tests randomly fail in the gate. Please be