Fix PY2/PY3 specific error in testcases

Use 'six.text_type' to wrap defined string value.

Change-Id: I229d58595494f59f03538be79de42f2e8007f442
Closes-Bug: #1697401
This commit is contained in:
TommyLike
2017-06-12 17:46:37 +08:00
parent 44e650a4ed
commit c1b03efe0f
2 changed files with 9 additions and 7 deletions

View File

@@ -10,6 +10,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
from cinderclient.tests.functional import base from cinderclient.tests.functional import base
@@ -42,10 +43,11 @@ class CinderSnapshotTests(base.ClientTestBase):
2) create snapshot with metadata 2) create snapshot with metadata
3) check that metadata complies entered 3) check that metadata complies entered
""" """
snapshot = self.object_create('snapshot', snapshot = self.object_create(
params='--metadata test_metadata=test_date {0}'. 'snapshot',
format(self.volume['id'])) params='--metadata test_metadata=test_date {0}'.format(
self.assertEqual("{u'test_metadata': u'test_date'}", self.volume['id']))
self.assertEqual(six.text_type({u'test_metadata': u'test_date'}),
snapshot['metadata']) snapshot['metadata'])
self.object_delete('snapshot', snapshot['id']) self.object_delete('snapshot', snapshot['id'])
self.check_object_deleted('snapshot', snapshot['id']) self.check_object_deleted('snapshot', snapshot['id'])

View File

@@ -108,7 +108,7 @@ class CinderVolumeTestsWithParameters(base.ClientTestBase):
1) create volume with metadata 1) create volume with metadata
2) check that metadata complies entered 2) check that metadata complies entered
""" """
volume = self.object_create('volume', volume = self.object_create(
params='--metadata test_metadata=test_date 1') 'volume', params='--metadata test_metadata=test_date 1')
self.assertEqual("{u'test_metadata': u'test_date'}", self.assertEqual(six.text_type({u'test_metadata': u'test_date'}),
volume['metadata']) volume['metadata'])