diff options
author | dineshbhor <dinesh.bhor@nttdata.com> | 2016-06-21 20:11:13 +0530 |
---|---|---|
committer | ChangBo Guo(gcb) <eric.guo@easystack.cn> | 2016-11-17 14:50:35 +0800 |
commit | 0f152eb66153e16d4d8aba0f8afebaab046aea35 (patch) | |
tree | becc23204c1d2fc5f9c3f1a1f77a6c71d6f57960 /nova/tests/unit/matchers.py | |
parent | 6a2b1e2c999bae482db6027afa9deef3d27852d1 (diff) | |
download | nova-0f152eb66153e16d4d8aba0f8afebaab046aea35.tar.gz |
[PY3] byte/string conversions and enable PY3 test
* The dict.items()[0] will raise a TypeError in PY3,
as dict.items() doesn't return a list any more in PY3
but a view of list.
* Webob response body should be bytes not strings so used
oslo_utils.encodeutils.safe_decode to decode it.
Partially implements blueprint: goal-python35
Co-Authored-By: ChangBo Guo(gcb) <eric.guo@easystack.cn>
Change-Id: I38d416923bc0cec0ca98c4494dd1e06cd49671cf
Diffstat (limited to 'nova/tests/unit/matchers.py')
-rw-r--r-- | nova/tests/unit/matchers.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/nova/tests/unit/matchers.py b/nova/tests/unit/matchers.py index e3729fd3c2..c2df5e4149 100644 --- a/nova/tests/unit/matchers.py +++ b/nova/tests/unit/matchers.py @@ -547,6 +547,12 @@ class EncodedByUTF8(object): except UnicodeDecodeError: return testtools.matchers.Mismatch( "%s is not encoded in UTF-8." % obj) + elif isinstance(obj, six.text_type): + try: + obj.encode("utf-8", "strict") + except UnicodeDecodeError: + return testtools.matchers.Mismatch( + "%s cannot be encoded in UTF-8." % obj) else: reason = ("Type of '%(obj)s' is '%(obj_type)s', " "should be '%(correct_type)s'." |