Pytest capture not working - caplog and capsys are empty

纵饮孤独 提交于 2020-12-15 06:55:13

问题


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

What am I doing wrong?


回答1:


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.

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



来源:https://stackoverflow.com/questions/61702794/pytest-capture-not-working-caplog-and-capsys-are-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!