diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-05-01 13:33:07 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-05-01 13:33:07 +0000 |
commit | 0063ebce2fd8d6259c128f5d161370d40296d510 (patch) | |
tree | 523474c6d5c6f99d1546743921719a6ab30108c5 | |
parent | dcbfbf2ea11994e9a6b983b34ba672363e0eb9ad (diff) | |
parent | 50e571c23d7cdee527826d9eaa70d467b3e63d25 (diff) | |
download | python-novaclient-0063ebce2fd8d6259c128f5d161370d40296d510.tar.gz |
Merge "Tags and Metadata fields with unicode cannot be correctly displayed" into stable/ocata7.1.1
-rw-r--r-- | novaclient/tests/functional/v2/test_servers.py | 19 | ||||
-rw-r--r-- | novaclient/utils.py | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/novaclient/tests/functional/v2/test_servers.py b/novaclient/tests/functional/v2/test_servers.py index 6adf1e05..7027413d 100644 --- a/novaclient/tests/functional/v2/test_servers.py +++ b/novaclient/tests/functional/v2/test_servers.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -134,9 +135,9 @@ class TestServersTagsV226(base.ClientTestBase): COMPUTE_API_VERSION = "2.26" - def _boot_server_with_tags(self): + def _boot_server_with_tags(self, tags=["t1", "t2"]): uuid = self._create_server().id - self.client.servers.set_tags(uuid, ["t1", "t2"]) + self.client.servers.set_tags(uuid, tags) return uuid def test_show(self): @@ -145,6 +146,20 @@ class TestServersTagsV226(base.ClientTestBase): self.assertEqual('["t1", "t2"]', self._get_value_from_the_table( output, "tags")) + def test_unicode_tag_correctly_displayed(self): + """Regression test for bug #1669683. + + List and dict fields with unicode cannot be correctly + displayed. + + Ensure that once we fix this it doesn't regress. + """ + # create an instance with chinese tag + uuid = self._boot_server_with_tags(tags=["中文标签"]) + output = self.nova("show %s" % uuid) + self.assertEqual('["中文标签"]', self._get_value_from_the_table( + output, "tags")) + def test_list(self): uuid = self._boot_server_with_tags() output = self.nova("server-tag-list %s" % uuid) diff --git a/novaclient/utils.py b/novaclient/utils.py index 7486ab29..e93df699 100644 --- a/novaclient/utils.py +++ b/novaclient/utils.py @@ -246,7 +246,7 @@ def print_dict(d, dict_property="Property", dict_value="Value", wrap=0): for k, v in sorted(d.items()): # convert dict to str to check length if isinstance(v, (dict, list)): - v = jsonutils.dumps(v) + v = jsonutils.dumps(v, ensure_ascii=False) if wrap > 0: v = textwrap.fill(six.text_type(v), wrap) # if value has a newline, add in multiple rows |