Skip to content

Commit 5808d35

Browse files
committed
更新异常测试
1 parent 9655753 commit 5808d35

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/test_except.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,30 @@
88
@time: 16-4-13 下午6:38
99
"""
1010

11+
import time
12+
import traceback
1113

1214
try:
1315
# raise Exception('error_message')
1416
raise Exception('error_message', 'error_code')
1517
except Exception as e:
18+
# 打印异常
19+
print type(e), e
20+
21+
time.sleep(0.1)
22+
23+
# 打印异常消息
1624
print type(e.message), e.message
17-
print type(e.args[0]), e.args[0]
25+
26+
time.sleep(0.1)
27+
28+
# 打印异常参数
29+
print e.args, type(e.args[0]), e.args[0]
30+
31+
time.sleep(0.1)
32+
33+
# 打印异常堆栈跟踪信息 stack traceback
34+
traceback.print_exc()
1835

1936

2037
if __name__ == '__main__':

0 commit comments

Comments
 (0)