summaryrefslogtreecommitdiff
path: root/nova/tests/unit/matchers.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests/unit/matchers.py')
-rw-r--r--nova/tests/unit/matchers.py6
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'."