python错误输出日志_如何强制Python单元测试在错误日志之后打印回溯?

我试图对一些复杂的网络进行单元测试,每次出现错误时,我的网络库都会输出数百行日志消息。我唯一感兴趣的是错误的实际回溯,但是我必须向上滚动所有这些日志消息才能看到回溯。在

有没有什么方法可以强制Python的unittest模块在日志之后输出回溯,而不是相反呢?在

例如,我目前看到的是:======================================================================

ERROR: my_test (tests.MyTest)

----------------------------------------------------------------------

Traceback (most recent call last):

File "my_code_file.py", line 39, in my_function

my_module.my_function()

File "my_code_file.py", line 78, in my_function

raise Exception("My exception here")

Exception: My exception here

-------------------- >> begin captured logging << --------------------

<<< hundreds of lines of logs from networking libraries/wiretraces/etc>>>

<<< hundreds of lines of logs from networking libraries/wiretraces/etc>>>

<<< hundreds of lines of logs from networking libraries/wiretraces/etc>>>

<<< hundreds of lines of logs from networking libraries/wiretraces/etc>>>

<<< hundreds of lines of logs from networking libraries/wiretraces/etc>>>

-------------------- >> end captured logging << --------------------

我希望看到这样的情况,以便在运行测试后快速看到错误:

^{pr2}$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值