From c1b03efe0f44bf3c07a9a44ea7db48a2b07ef3bc Mon Sep 17 00:00:00 2001 From: TommyLike Date: Mon, 12 Jun 2017 17:46:37 +0800 Subject: [PATCH] Fix PY2/PY3 specific error in testcases Use 'six.text_type' to wrap defined string value. Change-Id: I229d58595494f59f03538be79de42f2e8007f442 Closes-Bug: #1697401 --- .../tests/functional/test_snapshot_create_cli.py | 10 ++++++---- .../tests/functional/test_volume_create_cli.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cinderclient/tests/functional/test_snapshot_create_cli.py b/cinderclient/tests/functional/test_snapshot_create_cli.py index ea3d9e6..7ef5dfd 100644 --- a/cinderclient/tests/functional/test_snapshot_create_cli.py +++ b/cinderclient/tests/functional/test_snapshot_create_cli.py @@ -10,6 +10,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import six from cinderclient.tests.functional import base @@ -42,10 +43,11 @@ class CinderSnapshotTests(base.ClientTestBase): 2) create snapshot with metadata 3) check that metadata complies entered """ - snapshot = self.object_create('snapshot', - params='--metadata test_metadata=test_date {0}'. - format(self.volume['id'])) - self.assertEqual("{u'test_metadata': u'test_date'}", + snapshot = self.object_create( + 'snapshot', + params='--metadata test_metadata=test_date {0}'.format( + self.volume['id'])) + self.assertEqual(six.text_type({u'test_metadata': u'test_date'}), snapshot['metadata']) self.object_delete('snapshot', snapshot['id']) self.check_object_deleted('snapshot', snapshot['id']) diff --git a/cinderclient/tests/functional/test_volume_create_cli.py b/cinderclient/tests/functional/test_volume_create_cli.py index 2795b78..da4d5fb 100644 --- a/cinderclient/tests/functional/test_volume_create_cli.py +++ b/cinderclient/tests/functional/test_volume_create_cli.py @@ -108,7 +108,7 @@ class CinderVolumeTestsWithParameters(base.ClientTestBase): 1) create volume with metadata 2) check that metadata complies entered """ - volume = self.object_create('volume', - params='--metadata test_metadata=test_date 1') - self.assertEqual("{u'test_metadata': u'test_date'}", + volume = self.object_create( + 'volume', params='--metadata test_metadata=test_date 1') + self.assertEqual(six.text_type({u'test_metadata': u'test_date'}), volume['metadata'])