使用 Nose 运行单元测试时抑制 Cherrypy 的输出
我使用cherrypy 来实现网络服务器,并使用nose 来运行我的单元测试。然而,即使我使用 --nologcapture,nose 也会捕获并打印到标准输出的大量调试噪音,尤其是cherrypy 的日志消息。这使得测试输出非常难以阅读。
我认为:
def setUp(self):
cherrypy.config.update({ "server.logToScreen" : False })
cherrypy.config.update({'log.screen': False})
与 --nologcapture 选项一起会抑制这些消息,但显然它不会。
有人知道如何摆脱这些消息并获得干净的测试输出吗?
I'm using cherrypy to implement a web server and I use nose to run my unit tests. However, there is a lot of debug noise that nose catches and prints to stdout, even when I use the --nologcapture, particularly cherrypy's logging messages. That makes the testing output quite difficult to read.
I've thought that:
def setUp(self):
cherrypy.config.update({ "server.logToScreen" : False })
cherrypy.config.update({'log.screen': False})
together with --nologcapture option would suppress those messages, but apparently it does not.
Anyone knows how to get rid of those messages and have a nice clean test output, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有提及您使用的是哪个版本的 CherryPy,但根据您所遇到的情况假设为 3.x。我相信您需要添加以下配置选项:
我最近在 使用 Twill 测试 CherryPy 应用。
You did not mention which version of CherryPy you were using, but assuming 3.x based on what you are experiencing. I believe you need to add the following config option:
I was recently faced with the same issue when I was testing a CherryPy app with Twill.
我在使用 CherryPy 3.1.2 时遇到了这个问题。我切换到 3.2.2,问题就消失了,无需更改任何代码。
I was experiencing this problem with CherryPy 3.1.2. I switched to 3.2.2 and the problem went away without needing any code changes.