summaryrefslogtreecommitdiff
path: root/ceilometer/utils.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2015-07-30 23:28:38 +0200
committerVictor Stinner <vstinner@redhat.com>2015-07-31 01:19:29 +0200
commite8cb08fdbadd4c868027fd497d8e24cb915a3edc (patch)
tree34009e807b0a721f5ba6df6d0e2d1ad901c5f8f2 /ceilometer/utils.py
parent91dbb9f14862894fab7ac15e27922f6d94ddad2b (diff)
downloadceilometer-e8cb08fdbadd4c868027fd497d8e24cb915a3edc.tar.gz
Fix more tests on Python 3
* HTTP body type is bytes * query.py: Exception.message attribute was removed on Python 3 * mock calls cannot be sorted (mock calls are not comparable), use the assert_has_calls() with any_order=True instead. * Port decode_unicode() on Python 3: decode bytes from UTF-8 on Python 3 instead of encoding Unicode to UTF-8 * MeterDefinitionException: add message attribute * tox.ini: add more tests to Python 3.4 Change-Id: Iadd1c83b250d2f941262cc6e7dba4c27cb56893d
Diffstat (limited to 'ceilometer/utils.py')
-rw-r--r--ceilometer/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/ceilometer/utils.py b/ceilometer/utils.py
index 5405b599..42e2c20c 100644
--- a/ceilometer/utils.py
+++ b/ceilometer/utils.py
@@ -73,8 +73,10 @@ def decode_unicode(input):
# the tuple would become list. So we have to generate the value as
# list here.
return [decode_unicode(element) for element in input]
- elif isinstance(input, six.text_type):
+ elif six.PY2 and isinstance(input, six.text_type):
return input.encode('utf-8')
+ elif six.PY3 and isinstance(input, six.binary_type):
+ return input.decode('utf-8')
else:
return input