How can I see log messages when unit testing in PyCharm?

后端 未结 6 1281
忘掉有多难
忘掉有多难 2021-02-05 06:35

I\'m sure this is a simple fix, but I\'d like to view log messages in the PyCharm console while running a unit test. The modules I\'m testing have their own loggers, an

6条回答
  •  梦谈多话
    2021-02-05 07:13

    The only solution I've found is to do the normal logging setup at the top of the file with tests in it (assuming you're just running one test or test class): logging.basicConfig(level=logging.DEBUG). Make sure you put that before most import statements or the default logging for those modules will have already been set (that was a hard one to figure out!).

提交回复
热议问题