diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-03-11 08:00:05 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-03-11 08:00:05 +0000 |
commit | 5fba56d5c4fa5260c90720df79b02c19f38c9d2a (patch) | |
tree | 64c3f2776bdfaf4a80ff029eab4045830713e73f /ceilometerclient/tests/test_utils.py | |
parent | 0c23c62cef6f1388d26c04d6cf0e74153db0a0b5 (diff) | |
parent | f1f452405a80884c7a9cd78cad4aa4d73e290745 (diff) | |
download | python-ceilometerclient-5fba56d5c4fa5260c90720df79b02c19f38c9d2a.tar.gz |
Merge "Support unicode for alarm"
Diffstat (limited to 'ceilometerclient/tests/test_utils.py')
-rw-r--r-- | ceilometerclient/tests/test_utils.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ceilometerclient/tests/test_utils.py b/ceilometerclient/tests/test_utils.py index 6ef1fd1..23235d3 100644 --- a/ceilometerclient/tests/test_utils.py +++ b/ceilometerclient/tests/test_utils.py @@ -43,7 +43,8 @@ class UtilsTest(test_utils.BaseTestCase): with mock.patch('sys.stdout', new=six.StringIO()) as stdout: utils.print_dict({'alarm_id': '262567fd-d79a-4bbb-a9d0-59d879b6', - 'description': 'test alarm', + 'name': u'\u6d4b\u8bd5', + 'description': u'\u6d4b\u8bd5', 'state': 'insufficient data', 'repeat_actions': 'False', 'type': 'threshold', @@ -53,13 +54,15 @@ class UtilsTest(test_utils.BaseTestCase): '\\n description: test,' '\\n start: 0 18 * * *,' '\\n duration: 1,' - '\\n timezone: US}]'}) - self.assertEqual('''\ + '\\n timezone: US}]'}, + wrap=72) + expected = u'''\ +------------------+----------------------------------+ | Property | Value | +------------------+----------------------------------+ | alarm_id | 262567fd-d79a-4bbb-a9d0-59d879b6 | -| description | test alarm | +| description | \u6d4b\u8bd5 | +| name | \u6d4b\u8bd5 | | repeat_actions | False | | state | insufficient data | | statistic | avg | @@ -71,7 +74,11 @@ class UtilsTest(test_utils.BaseTestCase): | | timezone: US}] | | type | threshold | +------------------+----------------------------------+ -''', stdout.getvalue()) +''' + # py2 prints str type, py3 prints unicode type + if six.PY2: + expected = expected.encode('utf-8') + self.assertEqual(expected, stdout.getvalue()) def test_print_list(self): class Foo(object): |