From 922b56a92d89131063c969d543e8b73357b911e0 Mon Sep 17 00:00:00 2001 From: zhiyuan_cai Date: Mon, 23 May 2016 16:43:22 +0800 Subject: [PATCH] Fix test error caused by i18n Now oslo i18n _() returns a Message object which doesn't support addition, so put all the texts in _() to avoid error. Change-Id: I32ec2359200224e6e3e550bcca1e3fdf44b3d3c3 --- tricircle/common/exceptions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tricircle/common/exceptions.py b/tricircle/common/exceptions.py index 90d4e8c..7357631 100644 --- a/tricircle/common/exceptions.py +++ b/tricircle/common/exceptions.py @@ -59,11 +59,16 @@ class TricircleException(Exception): # log the issue and the kwargs exc_info = _('Exception class %s in string ' 'format operation') % type(self).__name__ + format_str = _('%(exception_info)s ; %(format_key)s : ' + '%(format_value)s') for name, value in kwargs.items(): - exc_info = exc_info + _(' ; ') + \ - name + _(' : ') + six.text_type(value) + exc_info = format_str % { + 'exception_info': exc_info, + 'format_key': name, + 'format_value': six.text_type(value)} - exc_info = self.message + _(' ; ') + exc_info + exc_info = _('%(message)s ; %(exception_info)s') % { + 'message': self.message, 'exception_info': exc_info} LOG.exception(exc_info) # no rerasie