summaryrefslogtreecommitdiff
path: root/tests/test_http.py
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2014-06-17 17:45:47 +1000
committerZhi Yan Liu <zhiyanl@cn.ibm.com>2014-06-18 23:01:25 +0800
commitdec9c9f3525577dd865bd12d43e4578ae32e4d3c (patch)
treea61e5e3d4323d12cb6a171fd7b3f5e07a68c1d8e /tests/test_http.py
parent3b694ca89f97ee0a68a58a1d1f7d8272db1aaabb (diff)
downloadpython-glanceclient-dec9c9f3525577dd865bd12d43e4578ae32e4d3c.tar.gz
Change a debug line to prevent UnicodeDecodeError issue
This debug line is causing tracebacks in the n-cpu logs for tempest runs. Its because the logged data is sometimes unicode: Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 846, in emit msg = self.format(record) File "/opt/stack/new/nova/nova/openstack/common/log.py", line 710, in format return logging.StreamHandler.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 723, in format return fmt.format(record) File "/opt/stack/new/nova/nova/openstack/common/log.py", line 674, in format return logging.Formatter.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 467, in format s = self._fmt % record.__dict__ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1234: ordinal not in range(128) Logged from file http.py, line 153 The change used correct encoding error handling policy for the log which may includes non-ascii char. Closes-bug: 1320655 Change-Id: I97f5f14b9beddcceb7fbd371062caf5a38a62a20
Diffstat (limited to 'tests/test_http.py')
-rw-r--r--tests/test_http.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_http.py b/tests/test_http.py
index 9310812..8dabdba 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -337,6 +337,16 @@ class TestClient(testtools.TestCase):
'timeout': 600.0}
self.assertEqual(expected, actual)
+ def test_log_curl_request_with_non_ascii_char(self):
+ try:
+ headers = {'header1': 'value1\xa5\xa6'}
+ http_client_object = http.HTTPClient(self.endpoint)
+ http_client_object.log_curl_request('GET',
+ 'http://www.example.com/\xa5',
+ {'headers': headers})
+ except UnicodeDecodeError as e:
+ self.fail("Unexpected UnicodeDecodeError exception '%s'" % e)
+
class TestHostResolutionError(testtools.TestCase):