django-nose and if you have the

Disable south debug logging when testing apps with nose

Sunday, June 17, 2012

If you’re testing your apps usingĀ django-nose and if you have the south database migration app installed, you will notice a high amount of debug messages in the terminal coming from south. This is because south itself sets the level of logging to debug. Unfortunately the south developers are currently not willing to change that.

To silence south, you can write a little nose-plugin, which sets the logging level of south from DEBUG to a level of your choice (e.g. ERROR). To achieve that, simply create a new python module containing the plugin:

nose_plugins.py:

1
2
3
4
5
6
7
8
9
from nose.plugins import Plugin
import logging

class SilenceSouth(Plugin):
    south_logging_level = logging.ERROR
    
    def configure(self, options, conf):
        super(SilenceSouth, self).configure(options, conf)
        logging.getLogger('south').setLevel(self.south_logging_level)

You can put nose_plugin.py anywhere in your project folder. In the second step you have to tell nose to use that plugin, and where it is located. To do this, simply add the following lines to the settings.py of your project:

settings.py

1
2
3
NOSE_PLUGINS = [
    '<your_project>.path.to.nose_plugins.SilenceSouth',
]

The result: no more annoying debug messages from south during testing.