Skip to content

Commit fb40166

Browse files
author
wallisyan
committed
modify logger_level;modify error_handle_test.py
1 parent feac129 commit fb40166

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

aliyun-python-sdk-core/aliyunsdkcore/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def add_endpoint(self, region_id, product_code, endpoint):
383383
self._endpoint_resolver.put_endpoint_entry(
384384
region_id, product_code, endpoint)
385385

386-
def set_stream_logger(self, log_level=logging.INFO, logger_name='aliyunsdkcore', stream=None,
386+
def set_stream_logger(self, log_level=logging.DEBUG, logger_name='aliyunsdkcore', stream=None,
387387
format_string=None):
388388
log = logging.getLogger(logger_name)
389389
log.setLevel(log_level)
@@ -395,7 +395,7 @@ def set_stream_logger(self, log_level=logging.INFO, logger_name='aliyunsdkcore',
395395
ch.setFormatter(formatter)
396396
log.addHandler(ch)
397397

398-
def set_file_logger(self, path, log_level=logging.INFO, logger_name='aliyunsdkcore'):
398+
def set_file_logger(self, path, log_level=logging.DEBUG, logger_name='aliyunsdkcore'):
399399
log = logging.getLogger(logger_name)
400400
log.setLevel(log_level)
401401
fh = logging.FileHandler(path)

python-sdk-functional-test/error_handle_test.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ class ErrorHandleTest(SDKTestBase):
1212

1313
# TODO make these test stronger with a mock server
1414

15-
def _parse_complex_error_message(self, error_message):
16-
obj = dict()
17-
lines = error_message.split('\n')
18-
head_message = lines[0].strip()
19-
for line in lines[1:]:
20-
key, value = line.strip().split(':', 1)
21-
obj[key.strip()] = value.strip()
22-
return head_message, obj
23-
2415
def test_server_timeout(self):
2516
acs_client = AcsClient(self.access_key_id, self.access_key_secret,
2617
"cn-hangzhou", timeout=0.001)
@@ -34,8 +25,8 @@ def test_server_timeout(self):
3425
assert False
3526
except ClientException as e:
3627
self.assertEqual("SDK.HttpError", e.error_code)
37-
head_message, attributes = self._parse_complex_error_message(e.get_error_msg())
38-
self.assertEqual("ecs-cn-hangzhou.aliyuncs.com", attributes.get("Endpoint"))
28+
self.assertEqual("HTTPConnectionPool(host='ecs-cn-hangzhou.aliyuncs.com',"
29+
" port=80): Read timed out. (read timeout=0.001)", e.get_error_msg())
3930

4031
def test_server_unreachable(self):
4132
from aliyunsdkcore.request import CommonRequest
@@ -46,8 +37,8 @@ def test_server_unreachable(self):
4637
assert False
4738
except ClientException as e:
4839
self.assertEqual("SDK.HttpError", e.error_code)
49-
head_message, attributes = self._parse_complex_error_message(e.get_error_msg())
50-
self.assertEqual("www.aliyun-hangzhou.com", attributes.get("Endpoint"))
40+
self.assertTrue(e.get_error_msg().startswith("HTTPConnectionPool(host='www.aliyun-hangzhou.com',"
41+
" port=80): Max retries exceeded with url:"))
5142

5243
def test_server_error_normal(self):
5344
from aliyunsdkecs.request.v20140526.DeleteInstanceRequest import DeleteInstanceRequest

0 commit comments

Comments
 (0)