Search code examples
pythoncherrypynose

Suppressing Cherrypy's output when running unit tests using Nose


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?


Solution

  • 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:

    cherrypy.config.update({ "environment": "embedded" })
    

    I was recently faced with the same issue when I was testing a CherryPy app with Twill.