Pytest捕获不起作用-Caplog和Capsys为空 [英] Pytest capture not working - caplog and capsys are empty

查看:280
本文介绍了Pytest捕获不起作用-Caplog和Capsys为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为记录器创建单元测试,但是-即使记录了事件-caplogcapsys仍然为空.

I am trying to create unit tests for a logger, but - even though the events are logged - the caplog and capsys remain empty.

我在做什么错了?

推荐答案

事实证明,我的记录器的属性propagate设置为False.结果,这些事件没有转发到pytest添加到根记录器的LogCaptureHandler中.

It turned out that my logger had property propagate set to False. As a result, the events were not forwarded to LogCaptureHandler added by pytest to the root logger.

caplogcapsys都取决于LogCaptureHandler接收传播的事件.

Both caplog and capsys depend on LogCaptureHandler receiving the propagated events.

这篇关于Pytest捕获不起作用-Caplog和Capsys为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆